I would like to decompress the files in different directories which are in different routes. And codes as below and the error is invalid data stream. Please help me out. Tha
bz2.decompress
takes compressed data and inflates it. You pass a filename, not the data in the file!
Do this instead:
zipfile = bz2.BZ2File(filepath) # open the file
data = zipfile.read() # get the decompressed data
newfilepath = filepath[:-4] # assuming the filepath ends with .bz2
open(newfilepath, 'wb').write(data) # write a uncompressed file