Skip to content

Instantly share code, notes, and snippets.

@jvilledieu
Last active November 27, 2015 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvilledieu/2ba2cb761effa5dca842 to your computer and use it in GitHub Desktop.
Save jvilledieu/2ba2cb761effa5dca842 to your computer and use it in GitHub Desktop.
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});
//Load the addresses
create index on :Adresse(name);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Adresse} as Adresse merge (:Adresse {name: Adresse});
create index on :CodePostal(name);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {CodePostal} as CodePostal merge (:CodePostal {name: CodePostal});
create index on :Ville(name);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Ville} as Ville merge (:Ville {name: Ville});
create index on :Region(name);
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Region} as Region merge (:Region {name: Region});
// connect postal codes and the addresses
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {CodePostal} as CodePostal, {Adresse} as Adresse match (adresse:Adresse {name:Adresse}), (codepostal:CodePostal {name:CodePostal}) create unique (adresse)-[:HAS_CODEPOSTAL]->(codepostal);
// connect the cities and postal codes
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {CodePostal} as CodePostal, {Ville} as Ville match (city:Ville {name:Ville}), (codepostal:CodePostal {name:CodePostal}) create unique (codepostal)-[:HAS_CITY]->(city);
// connect the region and cities
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Ville} as Ville, {Region} as Region match (region:Region {name:Region}), (ville:Ville {name:Ville}) create unique (ville)-[:HAS_REGION]->(region);
// connect the companies with code ape
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Siren} as Company, {Secteur} as CodeAPE match (company:Company {CodeSiren:Company}), (codeAPE:CodeAPE {name:CodeAPE}) create unique (company)-[:HAS_CODEAPE]->(codeAPE);
// connect the companies with forme
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Siren} as Company, {FormeJuridique} as FormeJuridique match (company:Company {CodeSiren:Company}), (formejuridique:FormeJuridique {name:FormeJuridique}) create unique (company)-[:HAS_FORMEJURIDIQUE]->(formejuridique);
// connect the companies with adresse
import-cypher -d";" -i file:c:/infogreffe2014.csv -b 10000 -q with distinct {Siren} as Company, {Adresse} as Adresse match (company:Company {CodeSiren:Company}), (adresse:Adresse {name:Adresse}) create unique (company)-[:HAS_ADRESSE]->(adresse);
//Load the companies
create index on :Company(CodeSiren);
import-cypher -d";" -i file:c:/infogreffe2015.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:/infogreffe2015.csv -b 10000 -q with distinct {FormeJuridique} as FormeJuridique merge (:FormeJuridique {name: FormeJuridique});
create index on :CodeAPE(name);
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {CodeAPE} as CodeAPE, {Secteur} as Secteur merge (:CodeAPE {name: Secteur, code: CodeAPE});
//Load the addresses
create index on :Adresse(name);
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Adresse} as Adresse merge (:Adresse {name: Adresse});
create index on :CodePostal(name);
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {CodePostal} as CodePostal merge (:CodePostal {name: CodePostal});
create index on :Ville(name);
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Ville} as Ville merge (:Ville {name: Ville});
create index on :Region(name);
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Region} as Region merge (:Region {name: Region});
// connect postal codes and the addresses
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {CodePostal} as CodePostal, {Adresse} as Adresse match (adresse:Adresse {name:Adresse}), (codepostal:CodePostal {name:CodePostal}) create unique (adresse)-[:HAS_CODEPOSTAL]->(codepostal);
// connect the cities and postal codes
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {CodePostal} as CodePostal, {Ville} as Ville match (city:Ville {name:Ville}), (codepostal:CodePostal {name:CodePostal}) create unique (codepostal)-[:HAS_CITY]->(city);
// connect the region and cities
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Ville} as Ville, {Region} as Region match (region:Region {name:Region}), (ville:Ville {name:Ville}) create unique (ville)-[:HAS_REGION]->(region);
// connect the companies with code ape
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Siren} as Company, {Secteur} as CodeAPE match (company:Company {CodeSiren:Company}), (codeAPE:CodeAPE {name:CodeAPE}) create unique (company)-[:HAS_CODEAPE]->(codeAPE);
// connect the companies with forme
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Siren} as Company, {FormeJuridique} as FormeJuridique match (company:Company {CodeSiren:Company}), (formejuridique:FormeJuridique {name:FormeJuridique}) create unique (company)-[:HAS_FORMEJURIDIQUE]->(formejuridique);
// connect the companies with adresse
import-cypher -d";" -i file:c:/infogreffe2015.csv -b 10000 -q with distinct {Siren} as Company, {Adresse} as Adresse match (company:Company {CodeSiren:Company}), (adresse:Adresse {name:Adresse}) create unique (company)-[:HAS_ADRESSE]->(adresse);
return timestamp();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment