虽然没有导入数据的向导,但假设您熟悉命令行(因为您在此站点,我敢打赌),将数据导入 ArangoDB 也很简单:
- 使用 Arango 导入工具将您的 CSV 文件导入到两个集合中
- 创建您的边缘集合
- 使用简单的 AQL 查询将数据插入到边缘集合中
以下是使用 arangoimp 导入 csv 的示例语法:
arangoimp --file <path/filename> --collection <collectionName> --create-collection true --type csv --server.database <databaseName> —server.username <username>
以下是一些常用选项:
翻译列名:
arangoimport --file "data.csv" --type csv --translate "from=_from" --translate "to=_to"
忽略空值(而不是抛出警告并且不加载数据),使用标志:
--ignore-missing
忽略导入文件中的列:
arangoimport --file "data.csv" --type csv --remove-attribute “attributeName”
此外,如果您在 csv 文件中已有边缘集合,您也可以直接导入:
arangoimp --file <path/filename> --collection <collectionName> --create-collection true --type csv --create-collection-type edge --server.database <databaseName>
最后,请注意上面列表中的 2 和 3 可以在 Arango GUI 中完成,如果您觉得那里更舒服的话。 3 的语句可能类似于
let newEdges = ( for csv1rec in csv1_collection
for csv2rec in csv2_collection
filter csv1rec.id = csv2rec.colA
return {from : csv1rec.id , to : csv2rec.colA} )
for rec in newEdges
insert {_from: rec.from, _to: rec.to} in edgeCollection
请注意,我是从内存中为第 3 步编写上面的 AQL,因此可能需要稍作调整。