I'm not sure about the specific terminology to my problem, so let me describe the exact problem itself:
test.csv
:
foo,char
"bar","µ"
test.py
:
#!/usr/bin/env python3
import csv
import json
with open('test.csv', mode='r') as file:
reader = csv.DictReader(file)
for row in reader:
print(json.dumps(row))
Expected output:
{"foo": "bar", "char": "µ"}
Actual output:
{"foo": "bar", "char": "\u00b5"}
I've tried adding encoding='utf-8'
to open()
but it doesn't change the output.