我的python程序从具有3列的CSV中读取,其中一列是日期时间对象。阅读它的代码如下:
t=[]
y=[]
h=[]
readFile = open('document.csv', 'r')
sepFile = readFile.read().split('\n')
readFile.close()
for idx, plotPair in enumerate(sepFile):
if plotPair in '. ':
# skip. or space
continue
if idx > 1: # to skip the first line
xAndY = plotPair.split(',')
time_string = xAndY[0]
time_string1 = datetime.strptime(time_string, '%d/%m/%Y %H:%M:%S')
t.append(time_string1)
y.append(float(xAndY[1]))
h.append(float(xAndY[2]))
print(len(y))
正在更新CSV,会向其添加新值。因此,阵列变得非常大。我怎样才能使用set_data或类似的东西?
t.set_data
似乎不适用于列表。