Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
merge (s:Session {event_key: csv.event_key, name: csv.name, date: date(csv.date), starttime: localtime(csv.starttime), endtime: localtime(csv.endtime)});
//add the descriptions (if existing) to the sessions
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
match (s:Session {event_key: csv.event_key})
set s.description=csv.description;
//creating this index after the insert
create index on :Session(description);
//check the temporal type properties
match (s:Session)
with s, duration.between(s.starttime, s.endtime) as duration
return s.name, duration.hours as hours, duration.minutesOfHour as dur
order by hours, dur desc;
//connect to event types
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
match (s:Session {event_key: csv.event_key})
merge (et:Event_Type {name: csv.event_type})
merge (s)-[:IS_OF_TYPE]->(et);
//add the venues
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
match (s:Session {event_key: csv.event_key})
merge (v:Venue {name: csv.venue})
merge (s)-[:TAKES_PLACE_IN]->(v);
//add the tags
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
with csv, split(csv.tags,";") as tags
where tags is not null
unwind tags as tag
match (s:Session {event_key: csv.event_key})
merge (t:Tag {name: tag})
merge (s)-[:HAS_TAG]->(t);
//create tags out of event subtypes
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
match (s:Session {event_key: csv.event_key})
where csv.event_subtype is not null
merge (t:Tag {name: csv.event_subtype})
merge (s)-[:HAS_TAG]->(t);
//add the speakers
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=494634359" as csv
with csv
where csv.speakers is not null
match (s:Session {event_key: csv.event_key})
merge (sp:Speaker {name: csv.speakers})
merge (sp)-[:SPEAKS_AT]->(s);
//add the speaker details
load csv with headers from "https://docs.google.com/spreadsheets/u/0/d/19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE/export?format=csv&id=19837_GxDh9d3HrZ0ZSm0vb1IbnWgG8BJD7SzQeeLTiE&gid=317311130" as csv
match (sp:Speaker {name: csv.name})
set sp.position = csv.position
set sp.about = csv.about
merge (c:Company {name: csv.company})
merge (sp)-[:WORKS_FOR]->(c);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.