Description
Code Sample
import pandas as pd
# data.csv is an empty file
df = pd.read_csv('data.csv', chunksize=20, header=None, names=['a', 'b', 'c'])
Problem description
read_csv
returns an empty DataFrame instead of a pandas.io.parsers.TextFileReader
object when the above code is run. While this isn't a big issue, it is unexpected and the only way to tell the file is empty (through Pandas) is to check if a DataFrame was returned by read_csv
. It would make more sense if None
was returned instead, or the TextFileReader
.
Expected Output
pandas.io.parsers.TextFileReader
object
Output of pd.show_versions()
pandas: 0.18.1
nose: None
pip: 9.0.1
setuptools: 25.1.1
Cython: None
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None