聲明我現在有存儲在一個CSV文件中這個CSV數據:如何,如果在Python
33.23,1376460060.0,01:01:00.000000
33.29,1376460060.25,01:01:00.250000
33.29,1376460060.5,01:01:00.500000
33.29,1376460060.75,01:01:00.750000
33.33,1376460061.0,01:01:01.000000
33.29,1376460061.25,01:01:01.250000
33.33,1376460061.5,01:01:01.500000
33.29,1376460061.75,01:01:01.750000
33.33,1376460062.0,01:01:02.000000
33.33,1376460062.25,01:01:02.250000
33.37,1376460062.5,01:01:02.500000
33.33,1376460062.75,01:01:02.750000
33.33,1376460063.0,01:01:03.000000
33.33,1376460063.25,01:01:03.250000
33.33,1376460063.5,01:01:03.500000
33.37,1376460063.75,01:01:03.750000
能有人幫我創造一個「if語句」或「while循環」,這將只顯示我這樣的:
33.33,1376460062.0,01:01:02.000000
33.33,1376460062.25,01:01:02.250000
33.37,1376460062.5,01:01:02.500000
33.33,1376460062.75,01:01:02.750000
,所以我可能會拿出平均列1
我讀我的文件是這樣的:
Input_Tiempo = raw_input("----INPUT TIME: ")
Full_InTi = Input_Tiempo
#This will convert Full_InTi to time in UNIX
Full_InTiUNIX = time.mktime(datetime.datetime.strptime("14:08:2013:"+Full_InTi, "%d:%m:%Y:%H:%M:%S.%f").timetuple())
#reads my csv file
DATOS = np.genfromtxt(csvname+'NEW.csv', delimiter=',', dtype=None)
LISTA = []
for COLUMN in DATOS:
INTC= eval(COLUMN[1])
INTF = float(Full_InTiUNIX)
if INTF <= INTC:
if INTF <= INTC:
print "D: "+COLUMN[0]+" TU: "+COLUMN[1] +" H: " + COLUMN[2]
LISTA.append(COLUMN[2])
到目前爲止我還沒有能力,它只會顯示我想要的。
您的決定標準不明確; 「拿出意思是」沒有道理。你爲什麼要這四條線,而不是其他12條線?你在寫** ** if語句的嘗試在哪裏? – Prune
爲什麼在那裏有一個'eval'? –