-1

I am using OrientDB ETL module to import a data from a CSV file to graph database. The format of the CSV file is as follows:

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

I want that once I import this into orientdb, each of a, b, c and d gets saved as a vertex in class and an edge is created starting from urlid_1 to urlid_2 with the edge weight as the corresponding score in the csv file.

Can anyone help me with the configuration (JSON) file for ETL??

I have tried the solution suggested here:Easiest way to import a simple csv file to a graph with OrientDB ETL but did not get expected results.

geisterfurz007
  • 5,292
  • 5
  • 33
  • 54

1 Answers1

0

Try this:

To import data:

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"},
            ]
    }
  }
}

To create edges:

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"}
            ]
    }
  }
}

Hope it helps

Regards

Michela Bonizzi
  • 2,622
  • 1
  • 9
  • 16