[Tutor] How to output dictionary data to CSV file :p:

Thomas C. Hicks paradox at pobox.com
Tue Apr 28 12:07:17 CEST 2015


On 04/28/2015 05:30 PM, Peter Otten wrote:
>>>> >>>data = {'B002':'NRP 2014','B003':'HBB 2015'}
>>>> >>>writer = csv.writer(sys.stdout)
>>>> >>>writer.writerows(data.items())
> B002,NRP 2014
> B003,HBB 2015
That is exactly what I was looking for!  Thanks, apparently my knowledge 
deficit is in understanding dictionary methods.
>
>> >How rude of me, I neglected to note I am using Python 3.4.3.
> And now you're top-posting to make it even worse;)
Lesson learned!

thomas



More information about the Tutor mailing list