I know this question has been asked before, but I think this context is a little different because I'm running into a different problem, where I get a TypeError that list indices must be integers, not tuples.
The code I have right now:
writer = csv.writer(open("test-new.csv", "wb"))
with open("test.csv", "r") as f:
reader = csv.reader(f)
for v in reader:
# does things
writer.writerow(v[0, 3])
I think this problem is happening because the script thinks I'm trying to write a tuple to a new csv file (test-new), when really I'm just trying to write those two values from the list of 4 values to a new csv.
Any ideas on how to tell python I'm not trying to write a tuple? Is it possible to do this using dictwriter
instead, possibly?
If my initial csv was like:
a, b, c, d
1, 2, 3, 4
5, 6, 7, 8
I would want my final output to look like:
a, d
1, 4
5, 8
Thanks!