I have several csv-files, some of which are compressed but others are not, all in a 7z archive. I want to read the csv files and save the content in a database. However, whenever py7zlib attemts to read the data from a csv file that is actually not compressed, I get the error data error during decompression.
import os import py7zlib scr = r'Y:\PathtoArchive' z7file = 'ArchiveName.7z' with open(os.path.join(scr,z7file),'rb') as f: archive = py7zlib.Archive7z(f) names = archive.filenames for mem in names: obj = archive.getmember(mem) print obj.compressed # prints None for uncompressed data try: data = obj.read() except Exception as er: print er # prints data error during decompression # whenever obj.compressed is None The error happens in
File "C:\Anaconda\lib\site-packages\py7zlib.py", line 608, in read data = getattr(self, decoder)(coder, data, level) File "C:\Anaconda\lib\site-packages\py7zlib.py", line 671, in _read_lzma return self._read_from_decompressor(coder, dec, input, level, checkremaining=True, with_cache=True) File "C:\Anaconda\lib\site-packages\py7zlib.py", line 646, in _read_from_decompressor tmp = decompressor.decompress(data) ValueError: data error during decompression So, how can I extract uncompressed data from a 7z-Archive?