Skip to content

Instantly share code, notes, and snippets.

@johnymontana
Last active April 25, 2016 08:58
Show Gist options
  • Save johnymontana/b661f86825310424e34f to your computer and use it in GitHub Desktop.
Save johnymontana/b661f86825310424e34f to your computer and use it in GitHub Desktop.
Travel hackathon datasets with Neo4j
// data available here: https://data.police.uk/data/
// Load data for City of London 2015. Change URL for other data downloaded from https://data.police.uk/data/
LOAD CSV WITH HEADERS FROM "https://dl.dropboxusercontent.com/u/67572426/london_graph_hack/2015-01-city-of-london-street.csv" AS row
WITH row WHERE row.Location IS NOT NULL AND row.Latitude IS NOT NULL AND row.Longitude IS NOT NULL AND row.Month IS NOT NULL AND row.`Falls within` IS NOT NULL AND row.`Reported by` IS NOT NULL AND row.`Crime type` IS NOT NULL AND row.`Crime ID` IS NOT NULL
MERGE (location:Location {name: row.Location})
MERGE (point:Point {lat: row.Latitude, lon: row.Longitude})
MERGE (month:Month {name: row.Month})
MERGE (juris:Jurisdiction {name: row.`Falls within`})
MERGE (report:Reporter {name: row.`Reported by`})
MERGE (crimetype:CrimeType {name: row.`Crime type`})
MERGE (crime:Crime {crime_id: row.`Crime ID`})
SET crime.lsoa_name = row.`LSOA name`,
crime.lsoa_code = row.`LSOA code`
MERGE (crime)-[:OCCURED_AT]->(point)
MERGE (point)-[:LOCATED_IN]->(location)
MERGE (location)-[:HAS_JURISDICTION]->(juris)
MERGE (crime)-[:OCCURED_DURING]->(month)
MERGE (crimetype)<-[:IS_TYPE]-(crime)
MERGE (crime)-[:REPORTED_BY]->(report)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment