Re: [Tutor] Writing a csv from a dictionary

2009-06-23 Thread Lie Ryan
Mark Tolonen wrote: > It's a good idea to cut-and-paste actual code and actual output. Your > above code doesn't work. I'd just like to clarify, in case someone misunderstood, it isn't a really good idea to simply cut-and-paste actual code and actual output for 2 reasons: 1) cut-and-paste means

Re: [Tutor] Writing a csv from a dictionary

2009-06-23 Thread Mark Tolonen
"Kent Johnson" wrote in message news:1c2a2c590906230415q351c7c74kebc591907ce0e...@mail.gmail.com... On Tue, Jun 23, 2009 at 1:08 AM, Mark Tolonen wrote: import csv dyc = { 'a50' : ['textfield', 50, 40], 'k77' : ['othertext', 60, 10] } myfile = open('csv-test.csv', 'w') mywriter = csv.writ

Re: [Tutor] Writing a csv from a dictionary

2009-06-23 Thread Kent Johnson
On Tue, Jun 23, 2009 at 1:08 AM, Mark Tolonen wrote: > import csv > > dyc = { > 'a50' : ['textfield', 50, 40], > 'k77' : ['othertext', 60, 10] > } > > myfile = open('csv-test.csv', 'w') > mywriter = csv.writer(myfile, dialect='excel') > > for k,[a,b,c] in dyc.items(): >   mywriter.writerow([k,a,b,

Re: [Tutor] Writing a csv from a dictionary

2009-06-22 Thread Mark Tolonen
"Eduardo Vieira" wrote in message news:9356b9f30906221404o7a7c5e5dt3d59e7b6d40ac...@mail.gmail.com... Hello, I have a dictionary similar to this: dyc = { 'a50' : ['textfield', 50, 40], 'k77' : ['othertext', 60, 10] } I was trying to write a csv with the csv module, by doing this: import csv m

[Tutor] Writing a csv from a dictionary

2009-06-22 Thread Eduardo Vieira
Hello, I have a dictionary similar to this: dyc = { 'a50' : ['textfield', 50, 40], 'k77' : ['othertext', 60, 10] } I was trying to write a csv with the csv module, by doing this: import csv myfile = open('c:/myscripts/csv-test.csv', 'wb') mywriter = csv.writer(myfile, dialect='excel') for item in