Hello;
I have a function that uses data from CSV file row by row, until the range has been used.
[Edited]
however I want to use the rest of rows of data automatically, each time it runs.
when it runs for the second time, I want it starts from where it was left off,
in this example that I have, for the second run it should read from row 2 to 4, and when it runs again for the 3rd time, it should read data from row 4 to 6.
so every time the file runs, it print 2 rows of data ( not the same row) until there is no data on CSV file.
is this doable?
your help is appreciated.
here is the part of read CSV file in range that works:
I have a function that uses data from CSV file row by row, until the range has been used.
[Edited]
however I want to use the rest of rows of data automatically, each time it runs.
when it runs for the second time, I want it starts from where it was left off,
in this example that I have, for the second run it should read from row 2 to 4, and when it runs again for the 3rd time, it should read data from row 4 to 6.
so every time the file runs, it print 2 rows of data ( not the same row) until there is no data on CSV file.
is this doable?
your help is appreciated.
here is the part of read CSV file in range that works:
with open('file1.csv', 'r') as f: for i, line in enumerate(f, start=0): if i in range(0, 2): print(line.rstrip()))Out put:
220445566 334587993