python - prevent DictReader from adding quotes -
i want convert csv python dict. keys strings values not.
vertical;"aaa";"bbb";"ccc" "one";1;none;3 two";11;22;{"t":"type","v":"value"} three";111;222;333
whatever use quoting , quotechar, dictreader adds quotes.
reader = csv.dictreader(open('matrix_test.csv'), delimiter=";") row in reader: component_type = row["vertical"] row.pop("vertical") matrix.update({component_type: row})
this get:
{'"one"': {'"aaa"': '1', '"bbb"': 'none', '"ccc"': '3'}, '"three"': {'"aaa"': '111', '"bbb"': '222', '"ccc"': '333'}, '"two"': {'"aaa"': '11', '"bbb"': '22', '"ccc"': '{"t":"type","v":"value"}'}}
but don't want quotes around numbers, dicts, , none. want them there put them in csv.
Comments
Post a Comment