We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6528209 commit 21f58d6Copy full SHA for 21f58d6
pandas/io/parsers.py
@@ -385,14 +385,20 @@ def _read(filepath_or_buffer, kwds):
385
raise NotImplementedError("'nrows' and 'chunksize' cannot be used"
386
" together yet.")
387
elif nrows is not None:
388
- data = parser.read(nrows)
389
- parser.close()
+ try:
+ data = parser.read(nrows)
390
+ finally:
391
+ parser.close()
392
return data
393
+
394
elif chunksize or iterator:
395
return parser
396
- data = parser.read()
397
398
+ data = parser.read()
399
400
401
402
403
404
_parser_defaults = {
0 commit comments