We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b833abd commit b625f08Copy full SHA for b625f08
pandas/io/formats/csvs.py
@@ -152,11 +152,15 @@ def save(self):
152
153
finally:
154
# GH 17778 handles zip compression for byte strings separately to
155
- # support Python 2
+ # support Python 2, also allow compression file handle
156
if not close and self.compression:
157
f.close()
158
- with open(f.name, 'rb') as f:
159
- data = f.read().decode(encoding)
+ if compat.PY2:
+ _fh = open(f.name, 'r')
160
+ else:
161
+ _fh = open(f.name, 'r', encoding=encoding)
162
+ with _fh:
163
+ data = _fh.read()
164
f, handles = _get_handle(f.name, self.mode,
165
encoding=encoding,
166
compression=self.compression)
0 commit comments