Hi!
I've been searching in OrientDB's documentation and could not find how to properly import a cvs file containing nodes and edges.
The csv file looks like this:
user_id,user_profile_id
1,2
1,53
1,52
1,62
Where a user_id has made an edit to a user_profile_id.
I have the following code:
final OrientGraphFactory factory = new OrientGraphFactory(
"plocal:" + DB_DIR, "user", "************");
System.out.println(factory.exists());
assert(!factory.exists());
OrientGraph graph = factory.getTx();
graph.getRawGraph().declareIntent( new OIntentMassiveInsert() );
BufferedReader br = new BufferedReader(new FileReader(dataset.csv));
String line;
int c = 0;
while ((line = br.readLine()) != null) {
String[] vertexes = line.split(",");
vertexes[1] = vertexes[1].replace("\r\n","");
Vertex v1 = graph.addVertex(vertexes[0]);
v1.setProperty("user_id", vertexes[0]);
Vertex v2 = graph.addVertex(vertexes[1]);
v2.setProperty("user_profile_id", vertexes[1]);
graph.addEdge(null,v1,v2, "edits");
if(++c%100000==0) {
System.out.println("Added "+ c + " edges");
graph.commit();
}
}
br.close();
My problem is that the vertexes are not unique (e.g. user_id '1' is added multiple times). Is there a way to make sure that the vertex only gets created when the vertex does not exist?