Neo4J LOAD CSV Notes

Load CSV is a Cypher Command to import data to a Neo4J Graph Database

In the Neo4J Manual there are two very useful chapters for start using this tool:

  1. Chapter 11.6 with a general description  of the query
  2. Chapter 12.8 with a working example
  3. If you have also the time, there is a great YouTube video on this tool.

Other options to import data on Neo4J is the Import Tool and the Batch Insertion. However I found the  Load CSV Cypher Query to be the most intuitive.

Issues that one may find hard to work out, using this tool, are:

1. Dealing with Boolean values.

In this case we have to use CASE

USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM "file:///C:/pepAll.csv"; AS csvLine
CREATE (:Protein { identifier: csvLine.identifier,
typpep: (case csvLine.typpep when "true" then true
else false end)});

2. Dealing with array properties on nodes or relationships.

In this case we have to use SPLIT where you can define the delimiter as well.

USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM "file:///C:/pepAll.csv"; AS csvLine
CREATE (:Protein { identifier: csvLine.identifier,
arrayproperty: SPLIT(csvLine.lastcolumn, ",")});

A more complex example can be found here 

3. Create a file with many load csv queries and perform them with neo4j-shell.

On windows from the GUI windows press options and then choose command prompt.

Then issue the command

Neo4jShell -path default.graphdb -file loadcsvfile.cql
Neo4J LOAD CSV Notes