I have a working function using loop, that works fine, in the example code I have, there are 4 CSV files, but it could go to 40 or more CSV files.
- this codes reads from first CSV file (file1.csv), loop from a range( in this example starts from row 0 to 3),
- use this data from the rows, (one at the time) to run the function,
- then it goes to the second CSV file and uses the data from same range(0-3), until the last CSV file.
I want to run this Python file on schedule (once,twice, or more daily), so I want to add another loop that when next time Python file runs, it reads CSV file from where it was left off. (row 3 to 6 in this example) for all CSV files, again the next time it runs, it starts from where it was left off ( row 6 t 9 in this example) and so on for all CSV files., of course this range is an example,
I am not sure if this is doable or not, I can not figure it out how to do that, appreciate your help.
here is the code I have:
from abc.zzz import xyz
path_id_map = [
{'path':'file1.csv', 'id': '12345678'},
{'path':'file2.csv', 'id': '44556677'}
{'path':'file3.csv', 'id': '33377799'}
{'path':'file4.csv', 'id': '66221144'}]
s_id = None
for pair in path_id_map:
with open(pair['path'], 'r') as f:
for i in range(0, 3):
zzz.func1(id_1=f.readline().rstrip(), B_id=pair['id'], s_id=s_id)
time.sleep(25)