数据导入教程,loadHDF5导入报错

教程链接,import_data.md · dolphindb/Tutorials_CN - Gitee.com

根据教程编写,loadHDF5,报错,数据都是从教程链接里面的附录里面下载的,提示:can't open dataset candle_201801. Invalid message format

代码:

login(`admin,`123456)

loadPlugin("D:/DophinDbSpace/DolphinDB_Win64_V1.20.22/server/plugins/hdf5/PluginHDF5.txt");

dataHdfFilePath = "C:/Users/Feng.Gao/Downloads/candle_201801.h5";

datasetName = "candle_201801";


use hdf5;

loadHDF5(dataHdfFilePath,datasetName);


根据教程编写,loadHDF5Ex,报错,提示:字段类型不匹配,The data type of partition column [tradingDay] doesn't match the partition scheme in dbHandle.

代码:

db=database("dfs://dataImportHdf5",VALUE,2018.01.01..2018.01.31);

schema = hdf5::extractHDF5Schema(dataHdfFilePath,datasetName)

hdf5::loadHDF5Ex(db,`cycle, `tradingDay, dataHdfFilePath,datasetName)



请先 登录 后评论

1 个回答

dongmange

第1个问题,datasetName要改成: "candle_201801.csv";

第2个问题,是因为导入的文件字段,tradingDay,默认不是date型,现新版本,loadHDF5Ex增加,transform函数,可以将数据类型进行转换,教程里面的可以修改为如下:

def datechange(mutable t){

return t.replaceColumn!(`tradingDay, t.tradingDay.format("00000000").temporalParse("yyyyMMdd") )

}

schemaHd = hdf5::extractHDF5Schema(dir+n, datasetName);

update schemaHd set type = `DATE where name = `tradingDay;

tb = table(1:0, schemaHd.name , schemaHd.type);

db.createPartitionedTable(tb, `cycle, `tradingDay)

hdf5::loadHDF5Ex(db, `cycle, `tradingDay, dir+n, datasetName ,,,, datechange);

详细教程请参考:

hdf5/README_CN.md · dolphindb/DolphinDBPlugin - Gitee.com

请先 登录 后评论
  • 1 关注
  • 0 收藏,356 浏览
  • Feng Gao 提出于 2021-09-23 18:20