Neo4j Cypher - Creating relationship using two CSV files -
i'm new neo4j , i'm working on build citation network.
i have 2 csv files 1 containing node properties , other containing relationship properties.
papers.csv -
paperid, title, year 123, abc, 1900 234, cde, 1902 456, efg, 1904 cites.csv -
fromid, toid 123, 234 234, 456 my graph should (123)--cites-->(234)--cites-->(456). using these files how create relationship between nodes?
you should avoid space in header names , in data too. if out of control can use trim function , backticks reference headername. normally, csv should clean. files should in import directory of neo4j. otherwise should comment out dbms.directories.import=import property in neo4j.conf.
you can create nodes this:
load csv headers "file:///papers.csv" line create (p:paper {paperid:trim(line.paperid), title: trim(line.` title`), year: trim(line.` year`)}); and can create relationships this:
load csv headers "file:///cites.csv" line match (p1:paper {paperid:trim(line.fromid)}) match (p2:paper {paperid:trim(line.` toid`)}) create (p1)-[:cites]->(p2);
Comments
Post a Comment