Database Reference
In-Depth Information
The CSV importer
Neo4j exposes the LOAD CSV command for importing data from the CSV files (with or
without headers). LOAD CSV can either use the CREATE or MERGE commands for import-
ing the data into the database.
Let's understand each of the available options.
LOAD CSV with CREATE
The following steps will guide you through the process of using the LOAD CSV command:
1. Let's create a file by the name neo4j-import.csv in the root of your
<$NEO4J_HOME> folder with the following content:
Name, WorkedAs
"Sylvester Stallone","Actor,Director"
"John G. Avildsen","Director"
"Ralph Macchio","Actor"
"Simon West","Director"
2. Once the CSV file is created, ensure that it has the following characteristics:
◦ The character encoding of a CSV file should be UTF-8
◦ End line termination is system dependent, for example, it is \n on Unix and
\r\n on Windows
◦ The default field terminator is ",", though you can change it by using the
FIELDTERMINATOR option
◦ Quoted strings are allowed in the CSV file and the quotes are removed
while reading the data
◦ The character for string quotation is double quotes "
◦ The escape character is \
3. In Unix, open <$NEO4J_HOME>/bin/neo4j-shell and enter the following
command; you will see that four nodes, four properties, and four labels are added:
LOAD CSV WITH HEADERS FROM "file://<$NEO4J_HOME>/
neo4j-import.csv" as csv
CREATE (cinestars:Cinestars {Name : csv.Name, WorkedAs
: split (csv.WorkedAs,",")});
Search WWH ::




Custom Search