Python Pandas Error tokenizing data

后端 未结 30 2245
不知归路
不知归路 2020-11-22 04:49

I\'m trying to use pandas to manipulate a .csv file but I get this error:

pandas.parser.CParserError: Error tokenizing data. C error: Expected 2 field

30条回答
  •  一向
    一向 (楼主)
    2020-11-22 05:48

    In my case the separator was not the default "," but Tab.

    pd.read_csv(file_name.csv, sep='\\t',lineterminator='\\r', engine='python', header='infer')
    

    Note: "\t" did not work as suggested by some sources. "\\t" was required.

提交回复
热议问题