Solution:
Add when reading files quoting=csv.QUOTE_ NONE
data = pd.read_ csv(path + ‘/’ + fn,quoting=csv.QUOTE_ NONE)
Quote mode is no reference. When reading, it is considered that the content is not surrounded by the default reference character (“).
Relevant knowledge points:
pandas.read_ CSV parameters
quoting : int or csv.QUOTE_* instance, default 0
Controls quotation mark constants in CSV.
Optional quote_ MINIMAL (0), QUOTE_ ALL (1), QUOTE_ NONNUMERIC (2) ,QUOTE_ NONE (3)
Other similar errors
1、pandas.errors.ParserError: Error tokenizing data. C error: Expected * fields in line *, saw *
solve:
Method A. add parameters when reading files error_ bad_ Lines = false # add parameters
data= pd.read_ csv(data_ file, error_ bad_ lines=False)
When reading CSV files, the separator defaults to comma. Analysis shows that a cell in the read data contains two fields, that is, the value may contain two commas
Method B. open the file to another format required by the dataset. Do not be lazy and modify the suffix directly. For example, some formats can be modified by converting Excel to CSV and saving manually to ensure uniform format
The fundamental reason is that the data format is incorrect, which makes it impossible to read correctly. We should solve it from the aspect of file content format