pandas dataframe读取csv,其末尾有/不带逗号的行

时间:2017-11-27 20:29:34

标签: python pandas csv dataframe

我的示例文件如下所示:

1.50424e+09,164.84,164.94,163.4,164.07,09:30:00,1.50424e+12,eAAPL,1.38904e+07,0,22.45,2.64333e+07,847097,18.49,1.54
1.50459e+09,163.8,164.25,158.26,162.2,09:30:00,1.50459e+12,eAAPL,2.54615e+07,0,22.44,2.64646e+07,847097,18.49,1.54
1.50467e+09,162.71,162.99,160.52,162.01,09:30:00,1.50467e+12,eAAPL,1.67919e+07,0,22.67,2.61136e+07,837180,18.27,1.55
1.50485e+09,160.9,161.15,158.62,158.7,09:30:00,1.50485e+12,eAAPL,2.02651e+07,0,22.73,2.48843e+07,832945,18.18,1.56,
1.50511e+09,160.51,162.05,159.89,161.48,09:30:00,1.50511e+12,eAAPL,2.44948e+07,0,22.54,2.50082e+07,819360,17.88,1.59,
1.50476e+09,162.17,163.69,160.36,161.175,09:30:00,1.50476e+12,eAAPL,1.88933e+07,0,22.68,2.58778e+07,836302,18.25,1.56,

请滚动到最右边,你会看到前3行最后没有逗号,但最后3行有逗号。当我做的时候

f = pd.read_csv("AAPL.csv", header=None)

它给出了错误说:

CParserError: Error tokenizing data. C error: Expected 15 fields in line 4, saw 16

我该如何解决?

0 个答案:

没有答案