I am trying to insert (update) values in a csv file whenever my code runs.
Here is my csv file content:
col1 | col2 | col3
value1,value2,value3
When I run my code, I want to only update value3 that is in col3. For example it would look like this after I run my script:
col1 | col2 | col3
value1,value2,newly_inserted_value3
Here is my code:
import csv
from csv import writer
file_name = 'my_file.csv'
with open(file_name, 'wb') as obj:
# Create a writer object from csv module
csv_writer = writer(obj)
# Add contents of list as last row in the csv file
csv_writer.writerow('new_value3')
However, it doesn't only insert the "new_value3" in col3. I am new to python so any ideas or suggestion would help.