Skip to content

Instantly share code, notes, and snippets.

@jvilledieu
Created January 16, 2017 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvilledieu/5e1e95b42ee84d95a4638ec31d5a0058 to your computer and use it in GitHub Desktop.
Save jvilledieu/5e1e95b42ee84d95a4638ec31d5a0058 to your computer and use it in GitHub Desktop.
Importing the Buzzfeed Trump World data into Neo4j (Based on Michael Hunger's work)
//Creating unique constraint
CREATE CONSTRAINT ON (o:Organization) ASSERT o.name IS UNIQUE;
//Importing the organizations and their connections
WITH 'https://docs.google.com/spreadsheets/u/1/d/1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss/export?format=tsv&id=1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss&gid=634968401' AS url, ['LOAN','LOBBIED','SALE','SUPPLIER','SHAREHOLDER','LICENSES','AFFILIATED','TIES','NEGOTIATION','INVOLVED','PARTNER'] as terms
load csv with headers from url as row fieldterminator '\t'
MERGE (a:Organization {name:row.`Organization A`})
MERGE (b:Organization {name:row.`Organization B`})
CREATE (a)-[:IS_CONNECTED_TO {type:row.Connection}]->(b);
//Adding some custom labels
MATCH (o:Organization)
WHERE o.name CONTAINS "BANK" SET o:Bank;
MATCH (o:Organization)
WHERE o.name CONTAINS "HOTEL" SET o:Hotel;
MATCH (o:Organization)
WHERE any(term in ["TRUMP","DT","DJT"] WHERE o.name CONTAINS (term + " "))
SET o:Trump;
@ajsnyde
Copy link

ajsnyde commented Nov 8, 2018

https://docs.google.com/spreadsheets/u/1/d/1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss/export?format=tsv&id=1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss&gid=634968401
Dead link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment