Last active
August 29, 2015 14:19
-
-
Save jvilledieu/dc41e62f2e3497718be2 to your computer and use it in GitHub Desktop.
FP7 projects. Sources: https://open-data.europa.eu/en/data/dataset/cordisfp7projects/resource/ad30f0d8-d528-48c5-9b5e-094288944f51 and https://open-data.europa.eu/en/data/dataset/cordisfp7projects/resource/0c211271-f36e-4e72-bdf6-ecff371a8306
This file contains hidden or 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
//----------------------- | |
//Import programs | |
//----------------------- | |
CREATE CONSTRAINT ON (a:PROGRAM) ASSERT a.programmePga IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7projects20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
WITH line | |
WHERE line.programmePga IS NOT NULL AND line.programmeCode IS NOT NULL | |
MERGE (a:PROGRAM { | |
programmePga: line.programmePga, | |
programmeCode: line.programmeCode | |
}); | |
//----------------------- | |
//Import countries | |
//----------------------- | |
CREATE CONSTRAINT ON (a:COUNTRY) ASSERT a.country IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7organisation20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
WITH line | |
WHERE line.country IS NOT NULL | |
MERGE (a:COUNTRY {country: line.country}); | |
//----------------------- | |
//Import projects | |
//----------------------- | |
CREATE CONSTRAINT ON (a:PROJECT) ASSERT a.rcn IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7projects20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
WITH line | |
WHERE line.rcn IS NOT NULL | |
MERGE (a:PROJECT {rcn: line.rcn}) | |
ON CREATE SET a.reference= line.reference, | |
a.acronym= line.acronym, | |
a.projectUrl = line.projectUrl, | |
a.totalCost = toInt(line.totalCost), | |
a.organisationId= line.organisationId, | |
a.subjects= line.subjects, | |
a.ecMaxContribution= toInt(line.ecMaxContribution), | |
a.subprogramme= line.subprogramme, | |
a.participants= line.participants, | |
a.participantCountries= line.participantCountries, | |
a.call= line.call, | |
a.title= line.title, | |
a.startDate= line.startDate, | |
a.endDate= line.endDate, | |
a.objective= line.objective, | |
a.fundingScheme= line.fundingScheme, | |
a.coordinator= line.coordinator, | |
a.coordinatorCountry= line.coordinatorCountry | |
; | |
//----------------------- | |
//Import organizations | |
//----------------------- | |
CREATE CONSTRAINT ON (a:ORGANIZATION) ASSERT a.NAME IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7organisation20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
WITH line | |
WHERE line.organisationName IS NOT NULL | |
MERGE (a:ORGANIZATION {organisationName: line.organisationName}) | |
ON CREATE SET a.organisationShortName= line.organisationShortName, | |
a.country= line.country, | |
a.street= line.street, | |
a.city= line.city, | |
a.postCode= line.postCode, | |
a.organizationUrl= line.organizationUrl | |
; | |
//----------------------- | |
//Import people | |
//----------------------- | |
CREATE CONSTRAINT ON (a:PEOPLE) ASSERT a.contactFullName IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7organisation20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
WITH line | |
WHERE line.contactFirstNames + line.contactLastNames IS NOT NULL | |
MERGE (a:PEOPLE {contactFullName: line.contactFirstNames + line.contactLastNames}) | |
ON CREATE SET a.contactType= line.contactType, | |
a.contactTitle= line.contactTitle, | |
a.contactFirstNames= line.contactFirstNames, | |
a.contactLastNames= line.contactLastNames, | |
a.contactFunction= line.contactFunction | |
; | |
//----------------------- | |
//Import subjects | |
//----------------------- | |
CREATE CONSTRAINT ON (a:SUBJECT) ASSERT a.name IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7projects20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
WITH line, split(line.subjects, ";") AS subjects | |
WHERE subjects IS NOT NULL | |
UNWIND subjects AS subject | |
MERGE (a:PROJECT {rcn: line.rcn}) | |
MERGE (b:SUBJECT {name: subject}) | |
MERGE (b)-[r:IS_SUBJECT_OF]->(a); | |
//----------------------- | |
//Relationships between projects and organizations | |
//----------------------- | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7organisation20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (b:PROJECT {rcn: line.projectRcn}) | |
MATCH (a:ORGANIZATION {organisationName: line.organisationName}) | |
MERGE (a)-[r:IS_RESPONSIBLE_OF {organisationRole: line.organisationRole}]->(b); | |
//----------------------- | |
//Relationships between organizations and people | |
//----------------------- | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7organisation20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (b:PEOPLE {contactFullName: line.contactFirstNames + line.contactLastNames}) | |
MATCH (a:ORGANIZATION {organisationName: line.organisationName}) | |
MERGE (b)-[r:IS_CONTACT_OF]->(a); | |
//----------------------- | |
//Relationships between organizations and countries | |
//----------------------- | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7organisation20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (a:ORGANIZATION {organisationName: line.organisationName}) | |
MATCH (b:COUNTRY {country: line.country}) | |
MERGE (b)-[r:IS_COUNTRY_OF]->(a); | |
//----------------------- | |
//Relationships between projects and programs | |
//----------------------- | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/fp7projects20150303.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (a:PROJECT {rcn: line.rcn}) | |
MATCH (b:PROGRAM {programmePga: line.programmePga}) | |
MERGE (a)-[r:IS_PART_OF_PROGRAM]->(b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment