[英]There is a error while opening the file: Error tokenizing data
#importing libraries
import sys
import os
import numpy as np
import pandas as pd
import csv
#main function
if __name__ == "__main__":
user_input=sys.argv[0]
user_input1=sys.argv[1:]
sample=pd.read_csv(user_input)
filename=user_input1
#initializing empty list for appending column values of data-type file
list1 = []
list2 = []
with open(filename,'r',newline="") as f:
reader=csv.DictReader(f)
There is error: pandas.errors.ParserError: Error tokenizing data.有错误:pandas.errors.ParserError:错误标记数据。 C error: Expected 1 fields in line 19, saw 3. How to resolve this error
C 错误:第 19 行应为 1 个字段,看到 3 个。如何解决此错误
You could try the following code你可以试试下面的代码
sample = pd.read_csv('Filename', error_bad_lines=False)
This could also be an issue of delimited in csv files.这也可能是 csv 文件中的分隔问题。 So try this if the above code doesnt work for you
所以如果上面的代码不适合你,试试这个
sample=pd.read_csv('Filename', sep='\t')
and place this line of code after the filename command并将这行代码放在 filename 命令之后
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.