如何将python代码中的for循环写入csv文件?

时间:2020-01-09 06:43:39

标签: python python-3.x pandas csv

在这段代码中,我尝试读取csv文件并查找总通过次数和失败次数,并且不得不将第二个for循环段插入到csv文件中。

    d=dfs[i]['Filename'].tolist()
    total=len(dfs[i].IngestionStatus)
    tpass=len(dfs[i][dfs[i]['IngestionStatus'] == 'Pass']) 
    tfail=total-tpass
    print ("SNo\t\tName\t\tTotal\t\tTotalPass\t\tTotalFail")
    print ("------------------------------------------------------------------------------------")
    for j in range(1):
        print ("%d:\t\t%s\t\t%d\t\t%d\t\t\t%d" % (j,d[j] ,total,tpass,tfail))
    print ("------------------------------------------------------------------------------------")```

Need to convert this section of the code into a table and insert it into a csv file 

0 个答案:

没有答案