[Python]:CSV中的数组:设置_数据而不是x.append

[Python]:CSV中的数组:设置_数据而不是x.append,python,arrays,list,csv,append,Python,Arrays,List,Csv,Append,我的python程序从包含3列的CSV中读取数据,其中一列是datetime对象。阅读代码如下: 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 continu

我的python程序从包含3列的CSV中读取数据,其中一列是datetime对象。阅读代码如下:

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_数据或类似数据


t.set\u数据
似乎不适用于列表。

能否提供一个csv文件的示例?首先,正确缩进代码。其次,为什么不使用
csv
模块?最后,什么是set_数据?熊猫将为您节省大量线路。为什么不为您的csv使用熊猫模块?它甚至可以解决您的问题。SCSV行看起来是这样的:03/05/2017 09:40:19,21.2,35.0,这里没有人真正正确地回答我的问题。如何使数组仅包含CSV在该时刻具有的值的数量?现在数组看起来是这样的:[all_values][all_values+1][all_values+2]