In line with this question, Let's say we have the following .csv
file to read with Python 3.7:
sep=,
A,B,C
1,2,3
4,"5,3",6
The Python code looks like this:
import csv
with open("tstSO.csv") as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
thisA = row["A"]
print(thisA)
Running this, I get KeyError: 'A'
in the error message. If I remove the sep=,
line, then I get the expected output:
1
4
Is there a way I can make python ignore/skip the line that indicated the delimiter? The actual files I need to work with are very large, so it would not be nice to do copy operations or manipulations meddling with the whole file. Of course, I also need to make operations on other columns and values, the code above is just a minimal working example.