-3

UPDATE:

I want python to print the next line like t+1 in the excel file into python output window when a condition is met . I believe the problem lies in this part of the code

 print "FA",row[0], ','.join(row[1:])

This prints the present day I need python to print the next day (t+1)

I tried print "FA",row[0], ','.join(row[1:]).nextline() but that does not work

for example lets say the excel file has

35F 1,0,1,0,1,1,1
66F 1,0,1,0,0,0,0

35F 1,0,1,0,1,1,1<-- at this moment python prints this part 

66F 1,0,1,0,0,0,0<--- **But I want python to print this {66F 1,0,1,0,0,0,0} this is the t+1**

Furthermore, here is the full code

import csv

with open('2015weather.csv', 'r') as file1:
     val = list(csv.reader(file1))[3]


with open('FAsince1900.csv', 'r') as file2:
    reader = csv.reader(file2)
    reader.next() # this skips the first row of the file
    # this iteration will start from the second row of file2.csv
    for row in reader:
        if row[1:] == val:
            print print "FA",row[0], ','.join(row[1:]) 

UPDATED 2: this is goal

ben olsen
  • 663
  • 1
  • 14
  • 27

1 Answers1

1

How about something like this:

conditionMet = False
for row in reader:
    if conditionMet == True:
        print "FA",row[0], ','.join(row[1:])
        conditionMet = False # or break if you know you only need at most one line
    if row[1:] == val:
        conditionMet = True
leekaiinthesky
  • 5,413
  • 4
  • 28
  • 39