You need to either use a csv.DictWriter()
instead (with matching fieldnames), or turn the dictionary row into a sequence:
writer.row([value for key, value in sorted(row.items())])
would output the values sorted by their key, for example.
Using a DictWriter
could be as simple as:
writer = csv.DictWriter(open('dict.csv','wb'), fieldnames=reader.fieldnames)
which would write the exact same fields, in the same order, as what your DictReader()
class is expecting.