I have 2 .csv files which both contain 3001 lines, and I have to do the same thing to both of them, so I was wondering if I can put it into 1 for loop.
So I thought to be smart and tried this:
self.csv_readingon = csv.reader(open('heisig6_reading_ja_on.csv'))
self.csv_readingkun = csv.reader(open('heisig6_reading_ja_kun.csv'))
for [d1, d2] in [self.csv_readingon, self.csv_readingon]:
for i, d in enumerate([d1, d2]):
# Do same stuff to both files
However this results in:
for [d1, d2] in [self.csv_readingon, self.csv_readingon]:
ValueError: too many values to unpack (expected 2)
Is it possible to put it this nicely in 1 for loop or should I make 1 for loop for 1 file (d1) and then manually assign a line from the 2nd csv file to d2?
Edit: The .csv files are not related to each other. Both are going to be put in a separate table in a SQLite database. So probably tuples are not the way to go. They just have the same structure, so only the table name will differ.