There are a number of tools that we can use to import external data into a Neo4j graph:
Neo4j Browser - it will run LOAD CSV statements but only one at a time
neo4j-shell - is a command line utility that comes pre-installed with Neo4j and will run multi-statement Cypher scripts to run against a graph database. Each statement must be terminated with a semicolon(;) and separated with an empty line
neo4j-import - is a command line utility that comes pre-installed with Neo4j and is designed for bulk loading massive datasets that exceed 10 million records. You can also use this tool to test far smaller datasets. However, note that your CSV files must follow a very specific format[1]
LazyWebCypher - an online web app that will run multi-statement Cypher scripts even against your own local Neo4j instance[2]
cycli - Cypher command-line interface[3]
soil_survey_sample.csv
, is in place sudo head -3 neo4j/import/soil_survey_sample.csv
Hort_Client,Contractor,Region,Locality,Soil_Service,Solution,Soil_Issue,Date_Reported,Date_Actioned,DaysToAction
159,1091,Northbury,3656,54593,5397,Erosion,2007-05-07,2008-02-18,287
159,1091,Northbury,1516,22644,5397,Erosion,2007-05-07,2008-03-18,316
soil_survey_import_to_neo4j_in_docker.cql
, is in place sudo head -2 neo4j/import/soil_survey_import_to_neo4j_in_docker.cql
CREATE INDEX ON :Hort_Client(client);
CREATE INDEX ON :Hort_Client(name);
sudo docker exec -ti $(sudo docker ps --format '{{.Names}}') bin/neo4j-shell -file import/soil_survey_import_to_neo4j_in_docker.cql
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
66 ms
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
11 ms
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 21
Properties set: 42
Labels added: 21
723 ms
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
19 ms
+-------------------+
| No data returned. |
+-------------------+
Indexes added: 1
15 ms
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 2670
Properties set: 5340
Labels added: 2670
980 ms
+-------------------+
| No data returned. |
+-------------------+
Relationships created: 2796
5457 ms
..
..
...
sudo docker exec -ti $(sudo docker ps --format '{{.Names}}') bin/neo4j-shell -c "CALL db.labels();"
+----------------+
| label |
+----------------+
| "Hort_Client" |
| "Soil_Service" |
| "Solution" |
| "Soil_Issue" |
| "Soil_Report" |
| "Contractor" |
| "Region" |
| "Locality" |
+----------------+
8 rows
15 ms
sudo docker exec -ti $(sudo docker ps --format '{{.Names}}') bin/neo4j-shell -c "CALL db.relationshipTypes();"
+------------------+
| relationshipType |
+------------------+
| "REQUESTS" |
| "RECOMMENDS" |
| "HAS" |
| "INVESTIGATES" |
| "CORRECTS" |
| "DISCUSSES" |
| "ISSUES" |
| "SENT_TO" |
| "ACTIONS" |
| "WORKS_AT" |
| "OPERATES_IN" |
| "PART_OF" |
+------------------+
12 rows
10 ms
CALL db.schema();
You have successfully populated Neo4j database using neo4j-shell utility and confirmed existence of new nodes and relationships