Hi Alexej,

Yes, but I don't understand how to import relations between two vertexes 
when they're already inserted. In the example there are two classes and 1 
relation. While in my example, there is 1 class and 1 relationship. Between 
the one class there are multiple relations. 
In my case: a user_id edits another user's profile page. 
 (http://snap.stanford.edu/data/wiki-Talk.html)
Can you help me out?

Casper


On Sunday, February 22, 2015 at 12:10:49 PM UTC+1, Alexej Bondarenko wrote:
>
> Hi Casper,
>
> have you already tried this method: 
> http://www.orientechnologies.com/docs/last/orientdb-etl.wiki/Import-from-CSV-to-a-Graph.html
>  
> ?
>
> Cheers,
> Alexej
>
> On Friday, February 20, 2015 at 10:32:13 AM UTC+1, CasperCLD wrote:
>>
>> 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?
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to