You don't use reader that csv module makes.
In line 15 you
So read in and make a nested list,then can replace values and keep csv structure.
In line 15 you
read()
all in as string.So read in and make a nested list,then can replace values and keep csv structure.
import csv with open('in.csv') as f: reader = csv.reader(f, delimiter=',') cars_info = [i for i in reader]Test:
>>> cars_info [['Id', 'Category', 'Description', 'Date'], ['1', 'Test', 'Red Cars', '02/12/2017'], ['2', 'Test', 'Blue Cars', '03/01/2017'], ['3', 'Test', 'Green, big cars', '01/05/2016']] >>> cars_info[3][2] 'Green, big cars' >>> cars_info[3][2] = "Green^ big cars" >>> cars_info [['Id', 'Category', 'Description', 'Date'], ['1', 'Test', 'Red Cars', '02/12/2017'], ['2', 'Test', 'Blue Cars', '03/01/2017'], ['3', 'Test', 'Green^ big cars', '01/05/2016']]