ParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file

    xiaoxiao2023-10-18  133

    报错:ParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file

    在使用pandas读取CSV文件的时候,报了上述错误,这是缓冲区溢出错误,造成这种错误的原因是CSV文件中每行使用了 \r ,也就是回车符。 解决方案就是给 read_csv 添加参数 lineterminator="\n" , 指定用“\n” 作为换行符。

    修改后的代码如下,不会报错。

    import pandas as pd path = "C:\\Users\\tzm\\Desktop\\python3\\data\\train.csv" emotion = pd.read_csv(path,lineterminator="\n")
    最新回复(0)