Database Reference
In-Depth Information
The spreadsheet way - Excel
Neo4j does not provide direct support for importing Excel documents; however, by lever-
aging the capabilities of Excel, we can create dynamic cypher queries and then execute all
those queries in a batch mode.
Let's consider an example and see how it works.
Assume that your data is organized in an Excel sheet, as per the following screenshot
where columns
A
,
B
, and
C
contain the data and column
D
contains the dynamic Cypher:
Columns
A
,
B
, and
C
are straightforward to understand as they contain plain data. The
tricky part is column
D
where we have entered the following Excel formula:
= "CREATE (n:"&C2&" {id:"&A2&", name: '"&B2&"'});"
Copy the same formula for all other rows and we get similar Cypher queries based on the
data provided in Columns
A
,
B
, and
C
.
Next, perform the following steps to create the batch import file:
1. Create a new empty file and save it as
import.txt
in your
<$NEO4J_HOME>
folder.
2. Edit
import.txt
and add
BEGIN
at the top of the file.
3. Copy the values of column
D
into
import.txt
, below the
BEGIN
line.
4. Add
COMMIT
to the end of the file.
5. Save
import.txt
.
6. Stop your Neo4j server.
The Neo4j server needs to be stopped because in the next step we will be using
Neo4j shell to start the Neo4j server in embedded mode and perform direct imports