I am reading a csv file and I use a split on every line but I do not fully understand the behavior.
csv file:
id;name;number
1111;foo \nbar;2.00
2222;a 0,25;1.00
code:
for file in csvs:
with open(file, encoding = "utf8") as f:
reader = csv.reader(f)
for row in reader:
if isinstance(row, str):
print(row)
else:
print(row[0].split(";"))
This yields:
['number', 'name', 'price']
['1111', 'foo \\nbar', '2.00']
['2222', 'a 0']
but I expected the last line to be:
['2222', 'a 0,25', '1.00']
2222;a 0as the first element; and then you split it by;subsequently. If you want to manually split each line, there is no need to usecsv.reader.