Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Matt Waite
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

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Bruno Desthuilliers
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, >

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Laszlo Nagy
> 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

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread skip
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 = {