pandas读取文本文件时报错
错误提示:pandas.errors.ParserError: Error tokenizing data. C error: EOF inside string starting at line 10042
解决方法:
import csv
import pandas as pd
df = pd.read_table(os.path.join(dir,file),sep='\t',encoding='utf-8',quoting=csv.QUOTE_NONE)
原因:
csv.QUOTE_MINIMAL is the default value and " is the default quotechar. If somewhere in your csv file you have a quotechar it will be parsed as a string until another occurrence of the quotechar. If your file has odd number of quotechars the last one will not be closed before reaching the EOF (end of file).
参考:https://stackoverflow.com/questions/18016037/pandas-parsererror-eof-character-when-reading-multiple-csv-files-to-hdf5