我正在尝试使用pandas read_csv函数读取* .dat文件。
df = pd.read_csv(file,skiprows=0,header=None,sep=" ",parse_dates=[[0,1]])
数据如下:
2019-06-01 04:00:22 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:00:32 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:00:42 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:00:52 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:01:02 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:01:12 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:01:22 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:01:32 PW 100 2000 2000 /// // // // ////// ////// ////
我收到标记错误:
ParserError: Error tokenizing data. C error: Expected 16 fields in line 242,saw 17
我认为是造成此错误的原因,因为第242行中的第6列中的值比之前的行中的低,例如列6保持为2000或具有4位数字的值(例如1501),但在第242行中降至991(三位数字)。
2019-06-01 04:39:32 PW 100 2000 2000 /// // // // ////// ////// ////
2019-06-01 04:39:42 PW 100 1501 2000 /// // // // ////// ////// ////
2019-06-01 04:39:52 PW 100 1501 2000 /// // // // ////// ////// ////
2019-06-01 04:40:02 PW 100 1501 2000 /// // // // ////// ////// ////
2019-06-01 04:40:12 PW 100 1187 2000 /// // // // ////// ////// ////
2019-06-01 04:40:22 PW 100 1187 2000 /// // // // ////// ////// ////
2019-06-01 04:40:32 PW 100 991 2000 /// // // // ////// ////// ////
如何摆脱这个错误?
error_bad_lines = False不能选择,因为我需要这些值