加载hdf5插件,用lsTable获取dataset:
loadPlugin("plugins/hdf5/PluginHdf5.txt")
dataFilePath="399006_daily_price.h5";
t = hdf5::lsTable(dataFilePath)
t
tableName tableDims tableType
/data/axis0 6 H5T_STRING
/data/axis1 3141 H5T_NATIVE_LLONG
/data/block0_items 6 H5T_STRING
/data/block0_values 6,3141 H5T_NATIVE_DOUBLE
用hdf5::loadHDF5(dataFilePath,t[1,0])查看日期数据如下:
col_0
20,100,104
20,100,105
20,100,106
20,100,107
20,100,108
20,100,111
20,100,112
...
20,140,224
用hdf5::loadHDF5(dataFilePath,t[3,0])得到数据如下:
col_0 col_1 col_2 col_3 col_4 col_5
1,472.69 1,571.4 1,460.41 22,434,815,758 1,543.97 877,397,135
1,465.98 1,468.0 1,415.25 15,556,867,452 1,452.06 620,306,044
...
1,434.89 1,436.8 1,393.00 12,343,402,635 1,410.40 503,420,747
也即/data/axis1中存放了date值,/data/block0_values中存放了Close,High,Low,Money,Open,Volume的值。这个是股票日频数据,请问如何将两个数据集合并,组合导入数据库?
我根据数据集导入的话只有分钟数据,问题是怎么对应日期呢?通过python 读取时直接就是二维数组是带日期的。我的代码示例如下:
login("admin","123456")
tableName = "1XSHE"
dfsPath = "dfs://StockInfo"
if(existsDatabase(dfsPath)){
dropDatabase(dfsPath)
}
db = database(dfsPath,VALUE, 930.. 1530)
dataFilePath="D://stockMinPrice/000001.XSHE.h5";
t = hdf5::lsTable(dataFilePath)
t
datasetName = t[3,0]
schema=hdf5::extractHDF5Schema(dataFilePath,datasetName)
update schema set name=`Close where name=`col_0
update schema set name=`High where name=`col_1
update schema set name=`Low where name=`col_2
update schema set name=`Money where name=`col_3
update schema set name=`Open where name=`col_4
update schema set type=`INT,name=`Time where name=`col_5
update schema set name=`Volume where name=`col_6
schema
tableName
hdf5::loadHDF5Ex(db,"wh000001","Time", dataFilePath,datasetName,schema)
dfsTable=loadTable(dfsPath,"wh000001")
select * from dfsTable limit 100000000