Skip to content

BUG: sniffing a csv raises with only a header #7773

Closed
@Nodd

Description

@Nodd

I'm trying to read a bunch of csv files, but some of them have a header line without any data. I expect to get empty data but Pandas raises an exception on these files:

Traceback (most recent call last):
  File "/usr/bin/positionneur_rng", line 9, in <module>
    load_entry_point('pymela==0.1.0', 'console_scripts', 'positionneur_rng')()
  File "/data/libs/python/pymela_scripts/positionneur_rng.py", line 203, in main
    = importer_csv_pandas(fichier)
  File "/data/libs/python/pymela_scripts/positionneur_rng.py", line 179, in importer_csv_pandas
    engine='python')
  File "/usr/lib/python3.4/site-packages/pandas/io/parsers.py", line 443, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/lib/python3.4/site-packages/pandas/io/parsers.py", line 235, in _read
    return parser.read()
  File "/usr/lib/python3.4/site-packages/pandas/io/parsers.py", line 686, in read
    ret = self._engine.read(nrows)
  File "/usr/lib/python3.4/site-packages/pandas/io/parsers.py", line 1506, in read
    self.index_names)
  File "/usr/lib/python3.4/site-packages/pandas/io/parsers.py", line 2129, in _get_empty_meta
    index = MultiIndex.from_arrays([[]] * len(index_col),
TypeError: object of type 'bool' has no len()

I used this command: pd.read_csv(fichier_data, sep=None, index_col=False, engine='python')
The file content is a single line:

TEMPS;MODE;STATUS;LATITUDE;LONGITUDE;ALTITUDE;VNORD;VEST;VHAUT;ROLL;PITCH;YAW;DELTA YAW;RATEX;RATEY;RATEZ;ACCX;ACCY;ACCZ;GISEMENT;SITE;CONAZ;CONEL;POSAZ;POSEL;LATCIBLE;LONGICIBLE;ALTICIBLE;DISTANCE;
>>> pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.4.1.final.0
python-bits: 64
OS: Linux
OS-release: 3.10.43-1-MANJARO
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8

pandas: 0.14.0
nose: 1.3.3
Cython: 0.20.2
numpy: 1.8.1
scipy: 0.14.0
statsmodels: None
IPython: 2.1.0
sphinx: 1.2.2
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.4
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.3.1
openpyxl: None
xlrd: 0.9.3
xlwt: None
xlsxwriter: 0.5.5
lxml: 3.3.5
bs4: 4.3.2
html5lib: 0.999
bq: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.6
pymysql: None
psycopg2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions