I have 2 CSV files of varying lengths. I'm looking for a pythonic way to loop over both of them, pulling data from predefined columns and append that data to my 2 list respectively.
So data from f1 goes to list_A and data from f2 goes to list_B
I realise using zip wont work as the number of rows in each file is different.
list_A = []
list_B = []
with open(file_1,'r') as f1, open(file_2,'r') as f2:
csvFile_1 = csv.reader(f1, delimiter=',')
csvFile_2 = csv.reader(f2, delimiter=',')
for x,y in zip(csvFile_1, csvFile_2):
list_A.append(x[1])
list_B.append(y[0])
Any pointers appreciated..