Home > other >  Pandas read_csv read CSV columns are not fixed
Pandas read_csv read CSV columns are not fixed

Time:12-05

The column number of the pandas read_csv is not fixed,
Found that is not specified the header, the default is 0, an error, if the specified header=1 or other lines, even if he is not header and the data columns are not fixed an error,
 
The import pandas as pd
Filename='222. CSV'
Df=pd read_csv (filename, encoding="utf-8")
Print (df)

Error:
Pandas. Errors. ParserError: Error tokenizing data. C Error: Expected 3 fields in line 4, saw six

222. The CSV content:
E, r
1, 2, 3
Aa, bb, cc
Triple a, b, bb, VVV, GGG, 88


consult everybody a great god, and how to read the whole content and print it out is not an error,


CodePudding user response:

I also encountered this problem, only to find a temporary solution, is to specify names, concrete is nams=[1, 2, 3... n], df=pd read_csv (file names=names)

CodePudding user response:

Do not specify the name, should be ok

CodePudding user response:

./222. CSV
  • Related