python - import csv with different number of columns per row using Pandas -
what best approach importing csv has different number of columns each row using pandas or csv module pandas dataframe.
"h","bbb","d","ajxxx dxxxs" "r","1","qh","dtr"," "," ","spxxt rixxls, raxxxd","1"
using code:
import pandas pd data = pd.read_csv("smallsample.txt",header = none)
the following error generated
error tokenizing data. c error: expected 4 fields in line 2, saw 8
supplying list of columns names in read_csv() should trick.
ex: names=['a', 'b', 'c', 'd', 'e']
https://github.com/pydata/pandas/issues/2981
edit: if don't want supply column names nicholas suggested
Comments
Post a Comment