I have a random csv file containing random numbers, comma separated. I'm doing some iteration, in order to filter data
if (int(row[0]) + i == int(row[1])) and int(row[1]) + i == int(row[2]) and int(row[2]) + i == int(row[3]) and int(row[3]) + i == int(row[4]):
do something
elif (int(row[0]) + i == int(row[1])) and int(row[1]) + i == int(row[2]) and int(row[2]) + i == int(row[3]):
do something
The If statements are so much more than that. My code obviously works perfectly, since there's nothing special about it.
I just wish to find a way to do what I'm doing without having to type
if row[0] and row[1] and row[2] and...
say the maximum is row[4] as shown in the example above,basically, i want to something, like a recursive function to do:
for n in range of 0 to 4
if row[n] +i == row[n+1]:
do something
row[n] == row[n-1]
if row[n-1] ...
I'm not quite sure how to do this, I hope my question is clear. I think this is a similar question in C#.
The part that I don't really know how to do, is how to get rid of and, I mean if i should write if... and ...and then I could just copy paste and do what I was doing, I want a better solution, if it exists.
If a solution exists, I'd prefer if it's a recursive one, because I am working hard to get rid of loops in my code.
if all(int(row[n])+i==int(row[n+1]) for n in range(4)): ...