ENH: Support bz2 compression in PY2 for c engine · pandas-dev/pandas@85630ea (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 85630ea

ENH: Support bz2 compression in PY2 for c engine

Closes #14874

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -621,8 +621,9 @@ cdef class TextReader:
621 621 if isinstance(source, basestring) or PY3:
622 622 source = bz2.BZ2File(source, 'rb')
623 623 else:
624 -raise ValueError('Python 2 cannot read bz2 from open file '
625 -'handle')
624 + content = source.read()
625 + source.close()
626 + source = compat.StringIO(bz2.decompress(content))
626 627 elif self.compression == 'zip':
627 628 import zipfile
628 629 zip_file = zipfile.ZipFile(source)