#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    39
    Rep Power
    3

    Some wield problem


    I just want to decompress a bz2 file and wrote a short script but

    it can't work. just the error:compressed file ended before the logical end-of-stream was detected

    I don't know how to fix it.Help me,please.

    Code:
    import bz2
    import os.path
    
    file_path = raw_input('input the compressed filename:\n')
    filename = os.path.basename(file_path)
    dest_path = raw_input('input the dest path.\n')
    dest_file = os.path.join(dest_path,filename)
    
    f = bz2.BZ2File(filename,'rU')
    
    ff = open(dest_file,'w')
    
    for line in f.readlines():
        ff.write(line)
    f.close()
    ff.close()
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Run the bunzip2 program.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo