Hi I'm using 3GB txt file and want to change it to CSV but it gives error_bad_lines ParserError: ' ' expected after '"'
Code I am using
df1 = df.read_csv("path\\logs.txt", delimiter = "\t", encoding = 'cp437',engine="python")
df1.to_csv("C:\\Data\\log1.csv",quotechar='"',error_bad_lines=False, header=None, on_bad_lines='skip')
CodePudding user response:
Try:
df1 = df.read_csv("path\logs.txt", delimiter = "\t", encoding = "cp437", engine="python")
df1.to_csv('C:\Data\log1.csv',quotechar='"',error_bad_lines=False, header=None, on_bad_lines='skip')
I think the issue is that you were mixing '
and "
within the same function.
CodePudding user response:
Add on_bad_lines=‘warn’ to your readcsv. Looks like there is some wrong line.