I have a CSV saved as data.csv that looks like this, with two columns:
Column1|Column2
Titleone|1.5
Title|two|2.5
Title3|3.6
The third row of data in the CSV contains a pipe operator, | that is causing the error. I need a way to read in the pipe operator as part of the Column1 value for the third row. When I run pd.read_csv("data.csv", sep = "|") I get the error: ParserError: Error tokenizing data. C error: Expected 2 fields in line 3, saw 3
I cannot use, on_bad_lines='skip' since I'm on an old version of Pandas. This is a workaround I found that seems to be a partial solution:
col_names = ["col1", "col2", "col3"]
df = pd.read_csv("data.csv", sep = "|", names = col_names)
Title|two|2.5. "Expected 2 fields, got 3" because it reads field1 = "Title", field2 = "two", field3 = 2.5.pd.read_csv(squeeze=True)