Last active
August 14, 2017 05:43
-
-
Save jvilledieu/ecbd1e503b9b8b84cab6 to your computer and use it in GitHub Desktop.
Import friends list scrapped from Facebook into Neo4j.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------------- | |
//Import people | |
//----------------------- | |
CREATE CONSTRAINT ON (a:PEOPLE) ASSERT a.id IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/my-facebook-network.csv" AS line | |
FIELDTERMINATOR ',' | |
WITH line | |
WHERE line.File = "common-friends.csv" | |
MERGE (a:PEOPLE {id: line.Target}); | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/my-facebook-network.csv" AS line | |
FIELDTERMINATOR ',' | |
WITH line | |
WHERE line.File = "friends.csv" | |
MERGE (a:PEOPLE {id: line.Source}); | |
//----------------------- | |
//Relationships between people | |
//----------------------- | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/my-facebook-network.csv" AS line | |
FIELDTERMINATOR ',' | |
MATCH (b:PEOPLE {id: line.Source}) | |
MATCH (a:PEOPLE {id: line.Target}) | |
MERGE (a)-[r:IS_FRIEND_WITH]->(b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment