Thanks everyone for your help. I got Skip's answer to work (mine is
pasted below):
import sys
import csv
last = {}
reader = csv.DictReader(open("/home/mwaite/test/test2.csv", "rb"))
writer = csv.DictWriter(open("/home/mwaite/test/test3.csv", "wb"),
['ZONE','CITY','EVENT'], dialect='excel')
for ro
Matt Waite a écrit :
> My first post, my first real python use, please be gentle:
>
> I have a CSV file, exported from Excel, that has blank records in it,
> and I need to fill them in with the values from the record just above
> it until it hits a non-blank value. Here's an example of the data,
>
> import csv
> citynew=''
> reader = csv.DictReader(open("/home/mwaite/test/test2.csv", "rb"))
> for row in reader:
> row['CITY'] == citynew
> else:
> citynew=row['CITY']
>
> The logic here -- in this case trying to fill in the city information
> -- would seem to work, but I'm not sure. An
Matt> I have a CSV file, exported from Excel, that has blank records in
Matt> it, and I need to fill them in with the values from the record
Matt> just above it until it hits a non-blank value.
Try something like:
#!/usr/bin/env python
import sys
import csv
last = {