I have a csv file with 2 columns:
1 A
2 B
3 C
4 D
My aim is to use Python to open the file, read it, randomize the order of the two lists (i.e. have 1 be with the same line as C, 2 with D etc.), and then save the new randomized lists in a different csv file.
I read some more stuff about writer, but am unsure how to use these functions yet.
The only problem is that I need to keep the columns headers intact, they can't be randomized. The code was as follows:
import csv
import random
with open ("my_file") as f:
l = list(csv.reader(f))
random.shuffle(l)
with open("random.csv", "W") as f:
csv.writer(f).writerows(f)