Skip to content

Commit 85630ea

Browse files
committed
ENH: Support bz2 compression in PY2 for c engine
Closes pandas-dev#14874
1 parent a7960f6 commit 85630ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/parser.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,9 @@ cdef class TextReader:
621621
if isinstance(source, basestring) or PY3:
622622
source = bz2.BZ2File(source, 'rb')
623623
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))
626627
elif self.compression == 'zip':
627628
import zipfile
628629
zip_file = zipfile.ZipFile(source)

0 commit comments

Comments
 (0)