Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
rvanbruggen / colruyt datascience homework assignment.cql
Created November 7, 2019 09:37
colruyt datascience homework assignment.cql
//colruyt datascience homework assignment in Neo4j
// from: https://github.com/MarkiesFredje/data-engineering-exercise/blob/master/data_engineer_exercise.ipynb
// json file download location: https://ecgplacesmw.colruytgroup.com/ecgplacesmw/v3/nl/places/filter/clp-places
//import into neo4j using apoc
//create indexes and constraint
create index on :Address(streetName);
create index on :City(name);
@rvanbruggen
rvanbruggen / keyvase.md
Created September 14, 2019 11:14
Keybase

Keybase proof

I hereby claim:

  • I am rvanbruggen on github.
  • I am rvanbruggen (https://keybase.io/rvanbruggen) on keybase.
  • I have a public key ASDwd7urEf8nfaDTlrdqflg_wBBOd6QBBMOX-4HYFq6mZAo

To claim this, I am signing this object:

//GRAPHGEMS
//10 (?) cypher queries that will blow your mind
//1. The meta-graph
MATCH (a)-[r]->(b)
WITH labels(a) AS a_labels,type(r) AS rel_type,labels(b) AS b_labels
UNWIND a_labels as l
UNWIND b_labels as l2
MERGE (a:Meta_Node {name:l})
MERGE (b:Meta_Node {name:l2})
@rvanbruggen
rvanbruggen / graphtechnologygraph_import.cypher
Last active December 18, 2022 01:54
Graph Technology Landscape Graph
create index on :Node(name);
//load the data in raw form
Load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/17WuC_B8RWzsSS8pw-NtY8qWeFFQGCGnCR5uXmENOFUI/export?format=csv&id=17WuC_B8RWzsSS8pw-NtY8qWeFFQGCGnCR5uXmENOFUI&gid=112267709" as csv
Merge (n:Node {name: csv.Name, type: csv.Type, tags: csv.Tags, link: csv.Link});
// move the 'type' property to a label and remove it as a property, USING APOC (not supported in Graphgist)
MATCH (n:Node)
with n, split(n.type, ",") AS futurelabels
unwind futurelabels as futurelabel
@rvanbruggen
rvanbruggen / import and clean data.cql
Last active November 28, 2018 10:48
ICIJ Medical Devices Dataset
//import the 3 csv files
USING PERIODIC COMMIT
LOAD CSV with headers from "https://docs.google.com/uc?export=download&id=1hNtMWHjrqOiMXU_xN7digO74ruzgCDeC" as line
CREATE (d:Device)
set d = line;
USING PERIODIC COMMIT
LOAD CSV with headers from "https://docs.google.com/uc?export=download&id=1lrMQNAF9k2ZeJJgfite85cvlHYpC7Ax8" as line
CREATE (e:Event)
set e = line;
@rvanbruggen
rvanbruggen / 1 - loadlineagedata.cql
Last active October 12, 2021 13:46
Demonstration of how to use the Neo4j Graph Database for Data Lineage
//load nodes
LOAD CSV WITH HEADERS FROM "https://docs.google.com/spreadsheets/u/0/d/1eL3IrbzgvZzkNnQUwDCZ1mwVfA6sypZYvDHBoeq48IM/export?format=csv&id=1eL3IrbzgvZzkNnQUwDCZ1mwVfA6sypZYvDHBoeq48IM&gid=0" AS csv
CALL apoc.create.nodes([csv.Label], [{id: csv.ID, name: csv.Name}]) YIELD node
RETURN count(node);
MATCH (n)
SET n:Node;
CREATE INDEX ON :Node(id);
@rvanbruggen
rvanbruggen / create_gped_db.cql
Last active October 19, 2018 04:05 — forked from jexp/graph_gist_template.adoc
Global Emission Power Database
//create indexes
create index on :Classification(name);
create index on :SubClassification(name);
create index on :FuelType(name);
create index on :Country(name);
create index on :Plant(name);
create index on :Plant(id);
//FROM FUELTYPE TAB
@rvanbruggen
rvanbruggen / create_graphconnectgraph.cql
Last active September 18, 2018 05:48
GraphConnectGraph New York City 2018
//import graphconnect 2018
create constraint on (s:Session)
assert s.event_key is unique;
create index on :Event_Type(name);
create index on :Session(name);
create index on :Speaker(name);
create index on :Tag(name);
create index on :Venue(name);
//import the sessions
@rvanbruggen
rvanbruggen / import_ROME.cql
Created August 29, 2018 13:43
Import ROME dataset into Neo4j
//import rome tree into Neo4j
load csv with headers from "https://docs.google.com/spreadsheets/d/1ks_hjKbO-n2We2glViM5D9RixU1ZtPi-0f7rJbfAY00/export?format=csv&id=1ks_hjKbO-n2We2glViM5D9RixU1ZtPi-0f7rJbfAY00&gid=744365839" as row
create (l:Leaf)
set l = row;
//set up the indexes
create index on :Leaf(Main);
create index on :Leaf(Category);
create index on :Leaf(Subcategory);
create index on :Leaf(Description);
@rvanbruggen
rvanbruggen / import_ESCO_csv_en.cql
Created August 23, 2018 11:26
ESCO database in Neo4j
//Import ESCO using CSV files
create index ON :Occupation(ISCOGroup);
create index ON :Occupation(altLabels);
create index ON :Skill(altLabels);
create index ON :ISCOGroup(code);
create index ON :Skill(conceptUri);
create index ON :ISCOGroup(conceptUri);
create index ON :Occupation(conceptUri);
create index ON :Occupation(preferredLabel);
create index ON :Skill(preferredLabel);