Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Excel如果条件为真,则打印下一行t+1_Python_Import From Csv - Fatal编程技术网

Python Excel如果条件为真,则打印下一行t+1

Python Excel如果条件为真,则打印下一行t+1,python,import-from-csv,Python,Import From Csv,更新: 我希望python在满足条件时将excel文件中的下一行(如t+1)打印到python输出窗口中。我相信问题在于这部分代码 print "FA",row[0], ','.join(row[1:]) 这将打印今天,我需要python打印第二天的t+1 我尝试打印FA,第[0]行,','。joinrow[1:]行。下一行 但这是行不通的 比如说 假设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<-- a

更新:

我希望python在满足条件时将excel文件中的下一行(如t+1)打印到python输出窗口中。我相信问题在于这部分代码

 print "FA",row[0], ','.join(row[1:])
这将打印今天,我需要python打印第二天的t+1

我尝试打印FA,第[0]行,','。joinrow[1:]行。下一行 但这是行不通的

比如说 假设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**
更新内容2:
像这样的东西怎么样:

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

你想要两份打印声明吗?我想你可能想要类似的东西,但目前还不清楚-你目前的问题到底是什么?我已经更新了这个问题,希望如此helps@benolsen如果所有行的大小相同,可以尝试使用file.readlinemethod@ben我下面的答案对你有用吗?
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