'Python csv.DictReader. Read alter dictionary then output to file

I need to read in a pipe delimited file change some fields and output. It reads in fine and I am able to change the columns. The writer part writes the header but writerows doesn't write anything. How can I output the updated contents?

csv.register_dialect('pipe',delimiter='|', quoting=csv,QUOTE_NONE)

with open('test.txt') as csvfile
    cfile=csv.DictReader(cfile,dialect='pipe')
    fieldnames=cfile.fieldnames
    for row in cfile:
        row['address']=scrubrow(row['address']
    

    with open('c.txt','w') as outfile:
        writer=csv.DictWriter(outfile,fieldnames=fieldnames,dialect='pipe')
        writer.writeheader()
        writer.writerows(cfile)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source