我想在这个文件中读取(的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