Version: 2.1.0

The LOAD CSV clause enables you to load and use data from a CSV file of your choosing in a row-based manner, within a query. We support the Excel CSV dialect, as it's the most commonly used one. For the syntax of the clause, please check the Cypher manual.

The clause reads row by row from a CSV file and binds the contents of the parsed row to the variable you specified.

##### For more detailed information about the LOAD CSV Cypher clause, check

To work with the LOAD CSV clause, we need to have access to our files. If working with Docker, check our Docker guide on how to access files from your local filesystem:

Below, you can find two examples of how to use the CSV Import Tool depending on the complexity of your data:

## Examples​

### One type of nodes and relationships​

Depending on how you set the HEADER option (WITH or NO), a row will be parsed as either a map or a list.

To access a given field, you can use the property lookup syntax. Let's assume that the contents of people_nodes.csv are as follows:

id,name100,Daniel101,Alex102,Sarah103,Mia104,Lucy

The contents of people_relationships.csv are the following:

id_from,id_to100,101100,102100,103101,103102,104

The following query will load row by row from the file, and create a new node for each row with properties based on the parsed row values:

LOAD CSV FROM "/path-to/people_nodes.csv" WITH HEADER AS rowCREATE (n:Person {id: row.id, name: row.name});

With the initial nodes in place, you can now create relationships between them:

LOAD CSV FROM "/path-to/people_relationships.csv"  WITH HEADER AS rowMATCH (p1:Person {id: row.id_from}), (p2:Person {id: row.id_to})CREATE (p1)-[:IS_FRIENDS_WITH]->(p2)

### Multiple types of nodes and relationships​

In the case of a more complex graph, we have to deal with multiple node and relationship types. Let's assume we have the following example:

Add the following to the file people_nodes.csv:

id,name,age,city100,Daniel,30,London101,Alex,15,Paris102,Sarah,17,London103,Mia,25,Zagreb104,Lucy,21,Paris

The following query will load row by row from the file, and create a new node for each row with properties based on the parsed row values:

LOAD CSV FROM "/path-to/people_nodes.csv" WITH HEADER AS rowCREATE (n:Person {id: row.id, name: row.name, age: ToInteger(row.age), city: row.city});