我正在使用OrientDB ETL模块将数据从CSV文件导入图形数据库。 CSV文件的格式如下:
urlid_1,urlid_2,score
a,b,10
a,c,20
a,d,30
b,a,40
b,c,50
b,d,60
c,a,70
c,b,80
c,d,90
d,a,100
d,b,110
d,c,120
我希望将其导入orientdb后,a
,b
,c
和d
中的每一个都会在类中保存为顶点并创建边缘从urlid_1
开始到urlid_2
,边缘权重为csv文件中相应的score
。
任何人都可以帮我处理ETL的配置(JSON)文件吗?
我已尝试过此处建议的解决方案:Easiest way to import a simple csv file to a graph with OrientDB ETL但未获得预期结果。
答案 0 :(得分:0)
试试这个:
导入数据:
<强> data_2.csv 强>
id
a
b
c
d
<强> import_2.json 强>
{
"source" : {
"file": { "path": "data_2.csv" }
},
"extractor" : {
"csv": {}
},
"transformers": [
{ "vertex": { "class": "Test" } }
],
"loader" : {
"orientdb": {
"dbURL": "plocal:your_path",
"dbUser": "your_user",
"dbPassword": "your_pwd",
"serverUser": "your_user",
"serverPassword": "your_pwd",
"dbType": "graph",
"classes": [
{"name": "Test", "extends":"V"},
]
}
}
}
创建边缘:
<强> data.csv 强>
urlid_1,urlid_2,score
a,b,10
a,c,20
a,d,30
b,a,40
b,c,50
b,d,60
c,a,70
c,b,80
c,d,90
d,a,100
d,b,110
d,c,120
<强> import.json 强>
{
"source" : {
"file": { "path": "data.csv" }
},
"extractor" : {
"csv": {}
},
"transformers": [
{ "command":
{ "command": "CREATE EDGE link FROM (SELECT FROM Test where id= "${input.urlid_1}") TO (SELECT FROM Test where id = "${input.urlid_2}") set score=${input.score}"}
}
],
"loader" : {
"orientdb": {
"dbURL": "plocal:your_path",
"dbUser": "your_user",
"dbPassword": "your_pwd",
"serverUser": "your_user",
"serverPassword": "your_pwd",
"dbType": "graph",
"classes": [
{"name": "link", "extends":"E"}
]
}
}
}
希望有所帮助
此致