Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Matt Waite
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, which is in a file called test2.

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