CSV文件输出:
Date (Column Header)
Week, 5-Dec, 4-Dec, 3-Dec, 2-Dec, 1-Dec
Week, 5-Dec, 4-Dec, 3-Dec, 2-Dec, 1-Dec
为文件中的每一行输出此值。
当前代码:
import csv
with open("C:\E\cs2.csv", 'r') as input, open('date.csv', 'w') as output:
reader = csv.reader(input, delimiter = ',')
writer = csv.writer(output, delimiter = ',',lineterminator='\n')
all = []
row = next(reader)
all.append(row)
for row in reader:
for d in ('Week','12-1','12-2','12-3','12-4','12-5'):
row.insert(5,d)
all.append(row)
writer.writerows(all)
问题:目前我正在编写每一行的每个日期,从第6列开始。我想在第6列循环上面列出的具体日期,但是以垂直方式。
Desired Output on Column 6:
Date(Column Header)
Week
12-1
12-2, etc.