Basically, this is what I am trying to do. I have an CSV file that I read in using Python 3. So, here is the basic layout of the rows:
Row1: On
Row2: <empty>
Row3: <empty>
Row4: On
Row5: On
Row6: <empty>
Row7: Off
Row8: <empty>
The code to access this would be:
for row in file:
var = row[0]
print(var)
The output I would like to see for each line after running the script would be:
for row in file:
print(var)
On
On
On
On
On
On
Off
Off
I am not sure how to do it, but I am trying to keep track of the variable as the program moves through the for loop. Here is the logic:
for loop:
1. If row[0] has the string 'On', then assign 'On' to var
2. If the next row[0] is empty, then I want the var to retain the previous value of 'On'.
3. Var will not change from 'On' until row[0] has a different value such as 'Off'. Then, Var will be assigned 'Off'.
Hopefully this question makes sense. I am not sure how to do this in Python 3.