ich möchte eine CSV-Datei schreiben. Der Dialekt lässt sich wie folgt beschreiben:
Code: Alles auswählen
with open('names.csv', 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=header.keys(),\
delimiter=';', quotechar='"', quoting=csv.QUOTE_NONNUMERIC)
Code: Alles auswählen
str(round(1.111,2)).replace('.',',')
Ich habe über pandas "to_csv" nachgedacht, das mehr Optionen anbietet, aber dasselbe Problem hat:
quoting optional constant from csv module. Defaults to csv.QUOTE_MINIMAL. If you have set a float_format then floats are converted to strings and thus csv.QUOTE_NONNUMERIC will treat them as non-numeric.