read_csv(, nrows=x) raises an StopIteration exception when given file doesn't contain any newlines · Issue #9535 · pandas-dev/pandas (original) (raw)

The problem occurs when using read_csv with nrows specified on a file that only contains a row of column names, but no newlines after that. An empty DataFrame would be expected but a StopIteration error is raised instead.

Code:

import pandas
pandas.read_csv(one_line_file, nrows=0)

INSTALLED VERSIONS

commit: None
python: 3.4.2.final.0
python-bits: 64
OS: Linux
OS-release: 3.16.0-28-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.14.1
nose: 1.3.4
Cython: None
numpy: 1.8.2
scipy: 0.14.0
statsmodels: None
IPython: None
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.0
pytz: 2012c
bottleneck: None
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 3.3.6
bs4: 4.3.2
html5lib: 0.999
httplib2: 0.9
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None