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.
here is the code: import csv reader = csv.reader(open('stateparty.csv')) counter = 1 fh = open('stateparty2.csv','w') writer = csv.writer(fh) for row in reader: if counter == 1: parties_row = row elif counter > 2: for index, column in enumerate(row[1:-1]): if column == "1": writer.writerow([row[0],parties_row[index+1]]) counter += 1 fh.close() and the output has something like this: Benue,ACN Benue,ANPP Benue,APGA Benue,CPC Benue,PDP Kogi,ACN Kogi,ADC Kogi,ANPP Kogi,APGA Kogi,CDC Kogi,CPC Kogi,DPP i am not expecting the spaces in between each line, kindly help with the challenge... thanks. -- Elegbede Muhammed Oladipupo OCA +2348077682428 +2347042171716 www.dudupay.com Mobile Banking Solutions | Transaction Processing | Enterprise Application Development
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor