用pandas读取csv格式文件时,里面有的行比前面的行 多出好多列,会报下面的错
df = pd.read_csv(file_name_csv,encoding="GBK")
File "pandas\_libs\parsers.pyx", line 905, in pandas._libs.parsers.TextReader._tokenize_rows
File "pandas\_libs\parsers.pyx", line 2042, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 9 fields in line 3, saw 21
解决方法是读取指定的列,这样就能保证全部行的列数相同了
df = pd.read_csv(file_name_csv, usecols=['时间','abc','操作类型','号码','Type','service','报竣返回','操作结果','处理说明'],encoding="GBK")
- ParserError tokenizing Expected pandas errorsparsererror tokenizing expected pandas parsererror tokenizing expected read_csv expected错误token 39 authentication manipulation token error parsererror expected quot incompatible expected version prop undefined expected invalid version expected metadata binary valueerror expected celery enough