我自学Python 2.7并且我很难用这段代码!我试图从CSV文件中提取数据并写入另一个CSV文件。这是我到目前为止所做的。第1行和第2行是日期(YYYY / MM / DD),我试图让第3行成为2个日期之间的差异。有谁知道如何做到这一点?它为"IOERROR: File not open for reading"
提供了"print row[0] in n"
。我该怎么办?!任何帮助都将是suuuuper欢迎!
谢谢!
Import CSV
n = open("newfile.csv", 'w')
with open("TestWorkbook3.csv", 'r') as o:
reader = csv.reader(o, delimiter=",")
for row in reader:
print row[0] in n
print row[1] in n
print row[2] in n
print difference in n
from datetime import date
difference = timedelta.days(row[2]-row[1])