0

This is part of my CSV file:

My CSV File

I have ";" as my delimiter but due to "Tr.Run on ; FL speed = Tr.run speed" at 4th line I'm getting this error: pandas.errors.ParserError: Error tokenizing data. C error: Expected 11 fields in line 4, saw 12

Code:

extension = 'csv'
all_filenames = [i for i in glob.glob('*.{}'.format(extension))]
combined_csv = pd.concat([pd.read_csv(__file__,sep=';',index_col= False).assign(Machine=os.path.dirname(os.path.abspath(__file__))) for __file__ in all_filenames ])
currentDateTime = datetime.now().strftime("%d-%m-%Y %H-%M-%S %p")
combined_csv.to_csv( f"combined_csv{currentDateTime}.csv", index= False, encoding='utf-8-sig')
DarrylG
  • 16,732
  • 2
  • 17
  • 23
SarangP
  • 3
  • 2
  • 1
    How do you know which `;` needs to be ignored and which `;` have to be kept? – Daweo Jul 20 '22 at 10:58
  • @Daweo The one on the 4th line of the CSV file: Tr.Run on ; FL speed= Tr.run speed, the ";" in this line should be ignored as its acting as a delimiter. I can just change it manually but there are 100s of files so that doesn't make sense to do it manually for each file. – SarangP Jul 21 '22 at 05:41

0 Answers0