我想发表声明并将结果导出到另一个名为EXPORT.csv
的CSV文件中。这是我的代码:
import csv
#import and export files
fichier2 = "/home/julien/excel/ABORD.csv"
file1 = open (fichier2, "rb")
fichier = "/home/julien/excel/EXPORT.csv"
file2 = open (fichier, 'wb')
reader = csv.reader (file1, delimiter = ';', quotechar=' ')
writer= csv.writer(file2, delimiter= ';', quotechar=' ')
#statements on file csv
for row in reader:
if row[2] == '':
print(row[1], "AD_REVE is NULL whereas it should not")
elif row[2]== "Neant":
print (row[1], "AD_REVE is Neant whereas it should not")
else:
print (row[1], "ok")
如何使用EXPORT.csv
writer.writerow ()
中导出所有这些结果?