Sep-11-2020, 06:37 PM
Hi, I have a question that it is possible easy to answer. I am importing a csv file into a dataframe but rows have different number of columns. I solved this adding names=range(100) and it worked fine:
datos=pd.read_csv('C:/Personal/datos.csv', delimiter=',', header=None, names=range(100))
Now I am trying to import multiple files and concatenate into one dataframe but I am having issues. This is the code I am currently using:
datos=pd.read_csv('C:/Personal/datos.csv', delimiter=',', header=None, names=range(100))
Now I am trying to import multiple files and concatenate into one dataframe but I am having issues. This is the code I am currently using:
import pandas as pd import glob df = pd.concat(map(pd.read_csv, glob.glob('C:/Personal/test/*.csv')))This small code is working well when rows have the same columns but I am having the same issue than before where rows have a different amount of columns and getting the following error:
Error:pandas.errors.ParserError: Error tokenizing data. C error: Expected 54 fields in line 3, saw 60
I suppose that I should add names=range(100) as before but not sure where. Thank you.