我想在這個文件中讀取(的test.txt)NumPy的genfromxt類型錯誤:數據類型不被理解錯誤
01.06.2015;00:00:00;0.000;0;-9.999;0;8;0.00;18951;(SPECTRUM)ZERO(/SPECTRUM)
01.06.2015;00:01:00;0.000;0;-9.999;0;8;0.00;18954;(SPECTRUM)ZERO(/SPECTRUM)
01.06.2015;00:02:00;0.000;0;-9.999;0;8;0.00;18960;(SPECTRUM)ZERO(/SPECTRUM)
01.06.2015;09:23:00;0.327;61;25.831;39;29;0.18;19006;01.06.2015;09:23:00;0.327;61;25.831;39;29;0.18;19006;(SPECTRUM);;;;;;;;;;;;;;1;1;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1;;;;;;;;;;;;(/SPECTRUM)
01.06.2015;09:24:00;0.000;0;-9.999;0;29;0.00;19010;(SPECTRUM)ZERO(/SPECTRUM)
...我與numpy的功能genfromtxt(試過)(請參見下面的代碼摘錄)。
import numpy as np
col_names = ["date", "time", "rain_intensity", "weather_code_1", "radar_ref", "weather_code_2", "val6", "rain_accum", "val8", "val9"]
types = ["object", "object", "float", "uint8", "float", "uint8", "uint8", "float", "uint8","|S10"]
# Read in the file with np.genfromtxt
mydata = np.genfromtxt("test.txt", delimiter=";", names=col_names, dtype=types)
現在,當我執行的代碼我碰到下面的錯誤 - >
raise ValueError(errmsg)ValueError: Some errors were detected !
Line #4 (got 79 columns instead of 10)
現在我認爲,困難來自於最後一列(val9)與許多;;;;;;;
這是很明顯,最後一列;
中的分隔符和符號是相同的!
如何在文件中讀取沒有錯誤的文件,也許有可能跳過最後一列,或僅替換最後一列中的;
?
標題錯誤與文本錯誤不匹配。 – hpaulj