Reputation: 524
I have a csv file with 38,0000,0000 rows, each line has two names which means two people know each other:
name,friend
a,b
a,c
a,d
f,a
e,a
d,g
I need to calculate all people relations.
firstly, I use cypher:
CREATE (n:Patent {name:'a'})
CREATE (n:Patent {name:'b'})
CREATE (n:Patent {name:'c'})
CREATE (n:Patent {name:'d'})
CREATE (n:Patent {name:'e'})
CREATE (n:Patent {name:'f'})
CREATE (n:Patent {name:'g'})
MATCH (a:Patent {name:'a'}),
(b:Patent {name:'b'})
MERGE (a)-[:CITED]->(b)
MATCH (a:Patent {name:'a'}),
(b:Patent {name:'c'})
MERGE (a)-[:CITED]->(b)
MATCH (a:Patent {name:'a'}),
(b:Patent {name:'d'})
MERGE (a)-[:CITED]->(b)
MATCH (a:Patent {name:'f'}),
(b:Patent {name:'a'})
MERGE (a)-[:CITED]->(b)
MATCH (a:Patent {name:'e'}),
(b:Patent {name:'a'})
MERGE (a)-[:CITED]->(b)
MATCH (a:Patent {name:'d'}),
(b:Patent {name:'g'})
MERGE (a)-[:CITED]->(b)
then, I got the result:
but the number of rows is too large, I tried load csv
batch import command:
:auto USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///friend_relation.csv" AS line
MATCH (a:Friend {name: line.name}),
(b:Friend {name: line.friend}) MERGE (a)-[:KNOWS]->(b)
It failed:
I split the big file into many samll file and use csv load
to achieve my goal, what is my problem?
Upvotes: 0
Views: 43
Reputation: 6514
If it doesn't return anything it is because the MATCH
clause doesn't find anything:
Try using
:auto USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///friend_relation.csv" AS line
MERGE (a:Friend {name: line.name})
MERGE (b:Friend {name: line.friend})
MERGE (a)-[:KNOWS]->(b)
Upvotes: 1