Skip to content

Instantly share code, notes, and snippets.

@apogiatzis
Last active February 21, 2023 18:02
Show Gist options
  • Save apogiatzis/7e53f828f0566980b935b314d575226d to your computer and use it in GitHub Desktop.
Save apogiatzis/7e53f828f0566980b935b314d575226d to your computer and use it in GitHub Desktop.
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/994b23af916ae7ee30665f1e4595739c/raw/20d3f719a734beddb08d3e38c24dac212884e55c/lab3_ex_persons.csv" AS csvLine
MERGE (e:Email {address: csvLine.email})
MERGE (t:Phone {number: csvLine.phone})
CREATE (p:Person {obj_id: csvLine.obj_id, first_name: csvLine.first_name, last_name: csvLine.last_name, date_of_birth: date(csvLine.date_of_birth), occupation: csvLine.occupation, nationality: csvLine.nationality, phone: csvLine.phone, ni_number: csvLine.ni_number})
CREATE (p)-[:HAS_EMAIL]->(e)
CREATE (p)-[:HAS_PHONE]->(t);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/726e0ed7416b530e40d81bc02ef32543/raw/678931d860273c8b903fa8005dfda1cf7cce7ede/lab3_ex_trusts.csv" AS csvLine
MATCH (beneficiary:Person {obj_id: csvLine.beneficiary})
MATCH (trustor:Person {obj_id: csvLine.trustor})
MATCH (trustee:Person {obj_id: csvLine.trustee})
CREATE (t:Trust {obj_id: csvLine.obj_id})
CREATE (beneficiary)-[:IS_BENEFICIARY_OF]->(t)
CREATE (trustor)-[:IS_TRUSTOR_OF]->(t)
CREATE (trustee)-[:IS_TRUSTEE_OF]->(t);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/0122070ba81e733be300054da6004894/raw/cae84f90d740bb27ee10d1dac5849557be5c012e/lab3_ex_shell.csv" AS csvLine
MATCH (beneficiary:Person {obj_id: csvLine.beneficiary})
MATCH (director:Person {obj_id: csvLine.director})
CREATE (c:ShellCompany {obj_id: csvLine.obj_id})
CREATE (beneficiary)-[:IS_BENEFICIARY_OF]->(c)
CREATE (director)-[:IS_DIRECTOR_OF]->(c);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/8e0f342294d5366fbf995aa1bb7d062e/raw/53fe6f920beae3bf7e89d129d509524098f37c52/lab3_ex_accounts.csv" AS csvLine
MATCH (p:Person {obj_id: csvLine.owners})
MERGE (b:Bank {name: csvLine.bank})
CREATE (a:Account {obj_id: csvLine.obj_id, balance: toFloat(csvLine.balance), currency: csvLine.currency, owner: csvLine.owners, opened_at: datetime(replace(csvLine.opened_at, ' ', 'T'))})
CREATE (p)-[:OWNS]->(a)
CREATE (a)-[:PROVIDED_BY]->(b);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/47c5fb33665140d8c06b20c00770b8b4/raw/94506667a8190853daf111b39c9e493c46f2e5a9/lab3_ex_trustaccs.csv" AS csvLine
MATCH (p:Trust {obj_id: csvLine.owners})
MERGE (b:Bank {name: csvLine.bank})
CREATE (a:Account {obj_id: csvLine.obj_id, balance: toFloat(csvLine.balance), currency: csvLine.currency, owner: csvLine.owners, opened_at: datetime(replace(csvLine.opened_at, ' ', 'T'))})
CREATE (p)-[:OWNS]->(a)
CREATE (a)-[:PROVIDED_BY]->(b);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/827f20e327973487ac5cb838d1d241e0/raw/adf6b860294fe7b054c290bfbec93211eec92be8/lab3_ex_shellaccs.csv" AS csvLine
MATCH (p:ShellCompany {obj_id: csvLine.owners})
MERGE (b:Bank {name: csvLine.bank})
CREATE (a:Account {obj_id: csvLine.obj_id, balance: toFloat(csvLine.balance), currency: csvLine.currency, owner: csvLine.owners, opened_at: datetime(replace(csvLine.opened_at, ' ', 'T'))})
CREATE (p)-[:OWNS]->(a)
CREATE (a)-[:PROVIDED_BY]->(b);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/74197bb4c59c23d82397e239ebd3ec9f/raw/46556f72087e9bebd4f44b4478ac77e37fbcaf5d/lab3_ex_txs.csv" AS csvLine
MATCH (sender:Account {obj_id: csvLine.sender})
MATCH (recipient:Account {obj_id: csvLine.recipient})
CREATE (t:Transaction:Transfer {obj_id: csvLine.obj_id, amount: toFloat(csvLine.amount), currency: csvLine.currency, type: csvLine.type, timestamp: datetime(replace(csvLine.timestamp, ' ', 'T'))})
CREATE (sender)-[:PERFORMED]->(t)
CREATE (t)-[:TO]->(recipient);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/9d8b681a6022ce6d37447502f70c4685/raw/aa8e8a3a726b82e0b32a34eb114c1d209000acb5/lab3_ex_deposits.csv" AS csvLine
MATCH (sender:Person {obj_id: csvLine.sender})
MATCH (recipient:Account {obj_id: csvLine.recipient})
CREATE (t:Transaction:Deposit {obj_id: csvLine.obj_id, amount: toFloat(csvLine.amount), currency: csvLine.currency, type: csvLine.type, timestamp: datetime(replace(csvLine.timestamp, ' ', 'T'))})
CREATE (sender)-[:PERFORMED]->(t)
CREATE (t)-[:TO]->(recipient);
LOAD CSV WITH HEADERS FROM
"https://gist.githubusercontent.com/apogiatzis/8cc00d8a913924793aac9a823ace4435/raw/9c531df44b5fce302799664a4c387057bc152f66/lab3_ex_assets.csv" AS csvLine
MATCH (n) WHERE n.obj_id = csvLine.owner
CREATE (a:Asset {obj_id: csvLine.obj_id, value_in_gbp: csvLine.value_in_gbp, asset_type: csvLine.asset_type, description: csvLine.description})
CREATE (n)-[:OWNS]->(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment