简体   繁体   中英

TypeError on Pandas read_csv

I am using read_csv in Pandas

data = pd.read_csv(dataset_path, sep=None, decimal='.')

and gives me back this error

File "pandas\_libs\parsers.pyx", line 398, in pandas._libs.parsers.TextReader.__cinit__

TypeError: object of type 'NoneType' has no len()

It is very strange because, according to Pandas documentation, this is supposed to work. What am I doing wrong?

According to documentation :

sepstr, default ','

Delimiter to use. If sep is None, the C engine cannot automatically detect the separator, but the Python parsing engine can, meaning the latter will be used and automatically detect the separator by Python's builtin sniffer tool, csv.Sniffer. In addition, separators longer than 1 character and different from '\s+' will be interpreted as regular expressions and will also force the use of the Python parsing engine. Note that regex delimiters are prone to ignoring quoted data. Regex example: '\r\t'.

For some strange reason, it was not using automatically Python parser engine. Setting the right sep parameter solved for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM