Hi,
I have a big bag of words array (words, and their counts) that I need to write to large flat csv file.
In testing with around 1000 or so words, this works just fine - I use the dictwriter as follows:
self.csv_out = csv.DictWriter(open(self.loc+'.csv','w'), quoting=csv.QUOTE_ALL, fieldnames=fields)
where fields
is list of words (i.e. the keys, in the dictionary that I pass to csv_out.writerow
).
However, it seems that this is scaling horribly, and as the number of words increase - the time required to write a row increases exponentially. The dict_to_list
method in csv
seems to be the instigator of my troubles.
I'm not entirely as to how to even begin to optimize here ? any faster CSV routines I could use ?