import CSV files

33 views
Skip to first unread message

Marwa Elabri

unread,
Nov 2, 2016, 10:18:33 AM11/2/16
to Neo4j
Hello,
I want to convert my relational database to Neo4j database
using LOAD CSV WITH HEADERS code
when I import entity classes it was good and all nodes are successfuly created
but when I want to import relationship classes it couldn't create relationships between nodes and it says no changes, no rows

My code is the following :

// create course nodes from course.csv
USING PERIODIC COMMIT LOAD
CSV WITH HEADERS FROM 'file:\\C:\\Program Files\\PostgreSQL\\9.2\\data\\course.csv' AS row
CREATE (:course { name : 'Course' + row.id, id: row.id, difficulty: row.difficulty});

//create student nodes from student.csv
USING PERIODIC COMMIT LOAD
CSV WITH HEADERS FROM 'file:\\C:\\Program Files\\PostgreSQL\\9.2\\data\\student.csv' AS row
CREATE (:student { name : 'Student' + row.id, id: row.id, intelligence: row.intelligence, ranking: row.ranking});

//create relationships "registration" between courses ans students from regisraion.csv
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:\\C:\\Program Files\\PostgreSQL\\9.2\\data\\registration.csv' AS row
MATCH (a:course{  course1fk : row.course1fk})
MATCH (b:student{  studentfk : row.studentfk})
CREATE (b)-[:registration {id: row.id, grade: row.grade}]->(a);

Mark Needham

unread,
Nov 2, 2016, 10:36:30 AM11/2/16
to ne...@googlegroups.com

I think your last query should read:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:\\C:\\Program Files\\PostgreSQL\\9.2\\data\\registration.csv' AS row

MATCH (a:course{  id : row.course1fk})
MATCH (b:student{  id: row.studentfk})


CREATE (b)-[:registration {id: row.id, grade: row.grade}]->(a);

The property name for course and student is different than the one you used when creating the nodes earlier on.


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

Reply all
Reply to author
Forward
0 new messages