简体   繁体   English

如何使用一个表中的ID和另一个表中的值在OrientDB中使用JSON在JSON中导入CSV?

[英]How import CSV using JSON in OrientDB using ID from one table and the values of another?

I have 3 CSV files: one for node A, one for node B and one for edge A_to_B. 我有3个CSV文件:一个用于节点A,一个用于节点B,一个用于边缘A_to_B。

I can import the nodes into OrientDB just fine. 我可以将节点导入OrientDB中就好了。 It's the edges that I'm having problems with. 这是我遇到的问题。

node a's CSV file contains (where id is integer index): 节点a的CSV文件包含(其中id为整数索引):

id, value
0, a
1, b
2, c
3, d
...

node b's CSV file contains (where id is a integer index): 节点b的CSV文件包含(其中id是整数索引):

id, Category
10, cat_x
11, cat_y
12, cat_z

edge_a_b CSV contains: edge_a_b CSV包含:

a_id, Category
0, cat_x
1, cat_z
2, cat_z
...

I can get the two "a" and "b" properly into the database. 我可以将两个“ a”和“ b”正确地放入数据库中。 However, when I run this ETL json... 但是,当我运行此ETL json时...

{
  "source": { "file": { "path": "/mypath/edge_a_b.csv" } },
  "extractor": { "csv": {} },
  "transformers": [
    { "vertex": { "class": "b", "skipDuplicates": true } },
    { "edge": { "class": "Involves", "joinFieldName": "a_id", "lookup": "a.id", "direction": "in" } }
  ],
  "loader": {
    "orientdb": {
       "dbURL": "plocal:../databases/mydb",
       "dbType": "graph",
       "classes": [
         {"name": "a", "extends": "V"},
         {"name": "b", "extends": "V"},
         {"name": "Involves", "extends": "E"}
       ], "indexes": [
         {"class":"a", "fields":["id:integer"], "type":"UNIQUE" },
         {"class":"b", "fields":["id:integer"], "type":"UNIQUE" }
       ]
    }
  }
}

I only get 1 of the 215 vertices I'm expecting matched. 我只得到期望的215个顶点中的1个。

| => ./oetl.sh /mypath/edge_a_b.json

OrientDB etl v.2.2.11 (build 2.2.x@r8b3a478e3ca7321a48e7cf0f5991569bbe06ed89; 2016-10-03 09:39:41+0000) www.orientdb.com
BEGIN ETL PROCESSOR
[file] INFO Reading from file /mypath/edge_a_b.csv with encoding UTF-8
Started execution with 1 worker threads
[orientdb] INFO committing
END ETL PROCESSOR
+ extracted 215 rows (0 rows/sec) - 215 rows -> loaded 1 vertices (0 vertices/sec) Total time: 172ms [0 warnings, 0 errors]

I have the nodes created. 我创建了节点。 It's the edges that I'm finding difficult to create. 这是我发现很难创建的边缘。 I've tried various approaches. 我尝试了各种方法。

You could use 你可以用

 "extractor": {"row": {}},
    "transformers": [{
            "csv": {
                "separator": ","
            }
        },
        {
        "command" : {
                "command" : "create edge Involves from (select from a where id= ${input.a_id}) to (select from b where Category= '${input.Category}')",
                "output" : "edge"
            }
        }
      ],

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用ETL将JSON导入OrientDB类型文档 - Import JSON to OrientDB type document using ETL 如何使用Database:Seeding将数据从一个表导入另一个表? (laravel 5.3)? - How to import data from one table to another table using Database: Seeding? (laravel 5.3)? 如何使用相同的链接ID从一个.json数据获取数据到另一个.json数据? - How to fetch and get data from one .json data to another .json data using the same linked id? 如何使用jq将来自不同JSON对象的值合并到一行CSV - How to combine values from different JSON objects to one line of CSV using jq 如何使用python从JSON添加csv中的日期时间值? - How to add date time values in csv from json using python? 从一个目录导入多个 JSON/csv 文件,然后使用 powershell 转换后移动到不同的目录 - Import multiple JSON/csv file from one directory then move to different directory after converted via using powershell 如何使用php将多个表记录从json导入到mysql - How to import multiple table records from json to mysql using php 使用JQ使用来自另一个JSON的值更新一个JSON文件值 - Update one JSON file values with values from another JSON using JQ 使用 JQ(在所有级别上)使用来自另一个 JSON 的值更新一个 JSON 文件值 - Update one JSON file values with values from another JSON using JQ (on all levels) 使用函数在Orientdb中返回JSON - Returned JSON in Orientdb Using Function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM