-3
UPDATE:Python的Excel中,如果條件爲真打印下一行T + 1
我想蟒蛇打印在Excel中如T + 1的下一行文件到Python的輸出窗口,當條件滿足。我認爲,問題出在代碼
print "FA",row[0], ','.join(row[1:])
這將打印本一天,我需要蟒蛇打印第二天的這一部分(T + 1)
我試圖print "FA",row[0], ','.join(row[1:]).nextline()
但不起作用
例如 可以說Excel文件有
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**
而且,這裏是完整的代碼
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:])
更新2:
你想兩個打印語句? – Levon 2015-03-19 12:02:54
我想你可能想要像http://stackoverflow.com/q/5434891/3001761這樣的東西,但目前還不清楚 - 目前你的問題到底是什麼? – jonrsharpe 2015-03-19 12:03:42
我已經更新了這個問題,希望這有助於 – 2015-03-19 19:08:01