I'm modifying a CSV file with two fieldnames and I would like to add a string to the end of each row under an additional fieldname. I've figured out how to add the fieldname, but not how to add things to it. It seems like it should be simple, but I'm stumped.
import csv
with open('test2l.csv', 'r') as inny:
reader = csv.DictReader(inny)
with open('outfile.csv', 'w') as outty:
fieldnames = ["Genus", "Species", "Source"]
writer = csv.DictWriter(outty, fieldnames = fieldnames)
writer.writeheader()
for record in reader:
g = record['Genus']
s = record['Species']
Everything I tried has just added the string to the existing string in 'Species' and I haven't been able to create a record for 'Source', I assume because it's empty.
Thanks!
record["Source"] = "something"then usewriter.writerow(record)what's the issue?