Skip to content

Instantly share code, notes, and snippets.

@jvilledieu
jvilledieu / import_datagreffe.cql
Last active November 27, 2015 17:43
Script pour importer les données Datagreffe dans Neo4j
//Load the companies
create index on :Company(CodeSiren);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q create (e:Company {CodeSiren: {Siren}, Denomination: {Denomination}, Geolocalisation: {Geolocalisation}, DateImmatriculation: {DateImmatriculation}, Greffe: {Greffe}, FicheEntreprise: {FicheEntreprise}});
//Load the codes
create index on :FormeJuridique(name);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {FormeJuridique} as FormeJuridique merge (:FormeJuridique {name: FormeJuridique});
create index on :CodeAPE(name);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {CodeAPE} as CodeAPE, {Secteur} as Secteur merge (:CodeAPE {name: Secteur, code: CodeAPE});
//Clean up the db
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//-----------------------
//Import players
//-----------------------
CREATE CONSTRAINT ON (a:PLAYER)
ASSERT a.id IS UNIQUE;
//Clean up the db
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//-----------------------
//Import people
//-----------------------
CREATE CONSTRAINT ON (a:EMPLOYEE)
ASSERT a.Employee_ID IS UNIQUE;
//Clean up the db
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//-----------------------
//Import lobbies
//-----------------------
CREATE CONSTRAINT ON (a:Lobby)
ASSERT a.Identification_number IS UNIQUE;
//The biggest tenders and the authorities behind it
Match (a:AUTHORITY)-[IS_AUTHORITY_OF]->(b:CONTRACT)
WHERE b.contract_contract_value_cost <> 'null'
RETURN b,a
ORDER BY b.contract_contract_value_cost DESC
LIMIT 10
//The biggest spenders
Match (a:AUTHORITY)
WHERE a.total_value_cost_eur <> 'null'
// Top Sellers
MATCH (t:Transfer)-[:FROM_CLUB]->(c)
WHERE t.transfer_season = '12/13'
RETURN c.club_name_short, sum(t.transfer_fee)
ORDER BY sum(t.transfer_fee) DESC
LIMIT 25
// Top Buyers
MATCH (t:Transfer)-[:TO_CLUB]->(c)
WHERE t.transfer_season = '12/13'
@jvilledieu
jvilledieu / transfer_early-summer_2015.csv
Created July 27, 2015 14:19
Data Jesus Barrasa scrapped on TransferMarkt about the early 2015 transfers
We can't make this file beautiful and searchable because it's too large.
"90/91","Aldair","/aldair/profil/spieler/4151","SL Benfica","Benfica","Portugal","AS Roma","AS Roma","Italy","Centre Back","24","6,30 Mill. £","6,30",1
"90/91","Thomas Häßler","/thomas-hassler/profil/spieler/553","1. FC Köln","1. FC Köln","Germany","Juventus FC","Juventus","Italy","Attacking Midfield","24","5,46 Mill. £","5,46",2
"90/91","Roberto Baggio","/roberto-baggio/profil/spieler/4153","AC Fiorentina","Fiorentina","Italy","Juventus FC","Juventus","Italy","Secondary Striker","23","5,43 Mill. £","5,43",3
"90/91","Karl-Heinz Riedle","/karl-heinz-riedle/profil/spieler/13806","SV Werder Bremen","Werder Bremen","Germany","SS Lazio","Lazio","Italy","Centre Forward","24","5,25 Mill. £","5,25",4
"90/91","Henrik Larsen","/henrik-larsen/profil/spieler/101330","Lyngby BK","Lyngby BK","Denmark","AC Pisa 1909","AC Pisa","Italy","Attacking Midfield","24","4,69 Mill. £","4,69",5
"90/91","Gheorghe Hagi","/gheorghe-hagi/profil/spieler/7939","Steaua Bucharest","Steaua","Romania","Real Madrid","Real Madrid","Spain","Attack
@jvilledieu
jvilledieu / import_all_transfers.cql
Created July 27, 2015 14:18
Jesus Barrasa script to import transfers
//Clean up the db
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//Load Players
USING PERIODIC COMMIT
LOAD CSV FROM "file:c:/all_transfers.csv" AS row
MERGE (:Player {player_name: row[1], player_url: row[2], player_position: row[9]});
@jvilledieu
jvilledieu / import_EU_tendersv2.cql
Last active October 24, 2022 20:23
Importing the European Union tenders into Neo4j
//-----------------------
//Clean everything
//-----------------------
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//-----------------------
//Import authorities
//-----------------------
@jvilledieu
jvilledieu / import_EU_tenders.cql
Last active August 29, 2015 14:23
Importing the European Union tenders into Neo4j
//-----------------------
//Import authorities
//-----------------------
CREATE CONSTRAINT ON (a:AUTHORITY) ASSERT a.contract_authority_official_name IS UNIQUE;
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/ted-contracts.csv" AS line
FIELDTERMINATOR ','
WITH line