[Tutor] CSV Ouptut concern...
delegbede at dudupay.com
Thu Mar 17 13:53:39 CET 2011
Thanks Tim, that worked like magic.
I now have another challenge on the same file, in this case, i am trying to
extract just a column as PARTY, I successfully wrote the header but instead
of having each element in a single excel block like this:
It is spelt out on different block like this:
PARTY A A C D A C N A C P N A D A D C A L P A N P P A P G
A A P S A R P B N P P C A P C D C C P C C P N C P P D F P F
D P P
what could be wrong with this code:
reader = csv.reader(open('stateparty.csv'))
counter = 1
header = ["PARTY"]
fh = open('stateparty3.csv','wb')
writer = csv.writer(fh)
for row in reader:
if counter == 1:
parties = row[1:-1]
for party in parties:
counter += 1
Thanks for your responses as anticipated.
On Thu, Mar 17, 2011 at 1:00 PM, Tim Golden <mail at timgolden.me.uk> wrote:
> On 17/03/2011 11:56, Dipo Elegbede wrote:
>> i wrote a code for extracting information from a csv file into another
>> csv file.
>> it worked well but i have an immediate challenge i can't seem to fix.
>> the new file that is created has an row and then an empty row and then a
>> row all through the file. how can i make the empty rows not be part of
>> the file.
> Open the file in binary mode:
> fh = open('stateparty2.csv','wb')
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
Elegbede Muhammed Oladipupo
Mobile Banking Solutions | Transaction Processing | Enterprise Application
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor