November 2017
Beginner to intermediate
204 pages
5h 23m
English
The last step is to save the results of applying the regular expression. In the following continuation of extract_street_names.py, an output CSV file called scf_street_name_data.csv is opened with write permission. This time, I've use a DictWriter object, which writes dictionaries to the output instead of Python lists:
....## read and iterate over the datafin=open("data/scf_address_data.csv","r",newline="")fout=open("data/scf_street_name_data.csv","w",newline="")reader = csv.DictReader(fin)headers=reader.fieldnamesheaders.append("street_name")writer = csv.DictWriter(fout,fieldnames=headers)........fin.close()fout.close()
Now the program is finally set up to write new data to the output file.
In this demonstration, ...
Read now
Unlock full access