Created
August 2, 2018 12:19
-
-
Save elisedeux/23954c8932ccfe94be7126a240688a82 to your computer and use it in GitHub Desktop.
Global_terrorism_database_Cypher_import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create node events | |
load csv with headers from "file:///bdd.csv" as row | |
merge(e:Event {id: row.eventid}) | |
set e.nature=row.attacktype1_txt | |
set e.year=row.iyear | |
set e.month=row.imonth | |
set e.date=row.iday | |
Set e.latitude=row.latitude | |
Set e.longitude=row.longitude | |
Set e.detail=row.summary | |
set e.nkill=row.nkill | |
// Create node City | |
load csv with headers from "file:///bdd.csv" as row | |
merge(c:City {id: row.city}) | |
Set c.details=row.location | |
// Create node Weapon | |
load csv with headers from "file:///bdd.csv" as row | |
merge(w:Weapon {id: row.weaptype1_txt}) | |
Set w.type=row.weapsubtype1_txt | |
// Create node TargetType | |
load csv with headers from "file:///bdd.csv" as row | |
merge(s:TargetType {id: row.targtype1_txt}) | |
Set s.subtype=row.targsubtype1_txt | |
// Create node Province | |
load csv with headers from "file:///bdd.csv" as row | |
merge(v:Province {id: row.provstate}) | |
// Create node Region | |
load csv with headers from "file:///bdd.csv" as row | |
merge(r:Region {id: row.region_txt}) | |
// Create node Target | |
load csv with headers from "file:///bdd.csv" as row | |
merge(t:Target {id: row.target1}) | |
set t.corporation=row.corp1 | |
set t.type=row.targtype1_txt | |
set t.subtype=row.targsubtype1_txt | |
// Create node Author | |
load csv with headers from "file:///bdd.csv" as row | |
merge(a:Author {id: row.gname}) | |
// Create node Country | |
load csv with headers from "file:///bdd.csv" as row | |
merge(cc:Country {id: row.country_txt}) | |
// Create relationship City-Event | |
load csv with headers from "file:///bdd.csv" as row | |
match (e:Event {id:row.eventid}) | |
match (c:City {id:row.city}) | |
merge(e)-[i:IS_LOCATED_IN]->(c) | |
// Create relationship Weapon-Event | |
load csv with headers from "file:///bdd.csv" as row | |
match (w:Weapon {id: row.weaptype1_txt}) | |
match (e:Event {id:row.eventid}) | |
merge(w)-[u:WAS_USED_FOR]->(e) | |
// Create relationship Author-Event | |
load csv with headers from "file:///bdd.csv" as row | |
match (a:Author {id: row.gname}) | |
match (e:Event {id:row.eventid}) | |
merge(a)-[p:PERPETRATED]->(e) | |
// Create relationship Author-Weapon | |
load csv with headers from "file:///bdd.csv" as row | |
match (a:Author {id: row.gname}) | |
match (w:Weapon {id: row.weaptype1_txt}) | |
merge(a)-[d:USED]->(w) | |
// Create relationship Target-Event | |
load csv with headers from "file:///bdd.csv" as row | |
match (e:Event {id:row.eventid}) | |
match (t:Target {id: row.target1}) | |
merge(e)-[tar:TARGETED]->(t) | |
// Create relationship Target-TargetType | |
load csv with headers from "file:///bdd.csv" as row | |
match (t:Target {id: row.target1}) | |
match (s:TargetType {id: row.targtype1_txt}) | |
merge(t)-[ts:TYPE_IS]->(s). | |
// Create relationship City-Province | |
load csv with headers from "file:///bdd.csv" as row | |
match (c:City {id:row.city}) | |
match (v:Province {id: row.provstate}) | |
merge(c)-[cp:IS_LOCATED_IN]->(v) | |
// Create relationship Province-Country | |
load csv with headers from "file:///bdd.csv" as row | |
match (v:Province {id: row.provstate}) | |
match (cc:Country {id: row.country_txt}) | |
merge(v)-[ts:IS_LOCATED_IN]->(cc) | |
// Create relationship Country-region | |
load csv with headers from "file:///bdd.csv" as row | |
match (cc:Country {id: row.country_txt}) | |
match (r:Region {id: row.region_txt}) | |
merge(cc)-[li:IS_LOCATED_IN]->(r) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment