【发布时间】:2016-02-21 20:26:42
【问题描述】:
import csv
f = csv.reader(open('lmt.csv','r')) # open input file for reading
Date, Open, Hihh, mLow, Close, Volume = zip(*f) #s plit it into separate columns
ofile = open("MYFILEnew1.csv", "wb") # output csv file
c = csv.writer(ofile)
item = Date
item2 = Volume
rows = zip(item, item)
i = 0
for row in item2:
print row
writer = csv.writer(ofile, delimiter='\t')
writer.writerow([row])
ofile.close()
以上是我目前制作的。
正如您在第 3 行中看到的,我从电子表格中提取了 6 列。
我想创建一个名为MYFILEnew1.csv 的.csv 文件,它只有两列,Date 和Volume。
我上面创建的 .csv 仅将 Volume 列写入新 .csv 文件的第一列。
如何将Date 放入第二列?
例如
Date Open High Low Close Volume
17-Feb-16 210 212.97 209.1 212.74 1237731
是我所拥有的。并且我想生成一个新的 csv 文件,使其具有
Date Volume
17-Feb-16 1237731
【问题讨论】:
标签: python python-2.7 csv