In this lesson, you will connect the Neo4j Data Importer to your sandbox, upload a CSV file, and create Person
nodes.
You can access Data Importer at https://workspace.neo4j.io.
A Neo4j sandbox was created for you when you enrolled on this course. You will need the connection details to connect the Neo4j Data Importer to your sandbox:
- Connection URL
-
{sandbox-host}:{sandbox-boltPort}
- Username
-
{sandbox-username}
- Password
-
{sandbox-password}
You can download the persons.csv
file data.neo4j.com/importing-fundamentals/persons.csv
Creating nodes
To create nodes in Neo4j using Data Importer, you will need to:
-
Connect to a Neo4j database
-
Upload a CSV file
-
Create a node
-
Map properties from the CSV file to the node
-
Run the import
Connect to your sandbox
A Neo4j sandbox was created for you when you enrolled on this course. You can connect the Neo4j Data Importer to your sandbox to import data.
-
Open the Import tab in Neo4j Workspace at https://workspace.neo4j.io.
-
Select the
Connect
button from the connection menu to connect to your sandbox. -
Enter the following details to connect to your Neo4j sandbox.
- Connection URL
-
{sandbox-host}:{sandbox-boltPort}
- Username
-
{sandbox-username}
- Password
-
{sandbox-password}
-
Click Connect.
Clear an existing model
If you have an existing data importer model, you can clear it by selecting the Clear all
option from the menu …
.
Any data import you run will be against the connected Neo4j database.
Upload a file
Data Importer can import data from CSV (Comma Separated Values) and TSV (Tab Separated Values) files.
You need to upload the file to Data Importer before importing from it.
All the CSV source files you need for this course are available to download.
The persons.csv
file contains data about people in movies.
You will use Data Importer to import this data and create Person
nodes.
-
Download the
persons.csv
file. -
Upload the
persons.csv
file to Data Importer using theFiles
panel. -
Once uploaded, the file and its contents will be displayed.
The persons.csv
file contains fields such as name
, born
, bio
, and person_tmdbId
.
You will use the data in this file to create Person
nodes and their properties.
Create a Person node
To create new nodes in Data Importer you must create a new node label, before mapping the fields from the CSV file to node properties.
-
Add a new node label.
-
Label the node as
Person
in theDefinition
panel. -
The
persons.csv
file should be automatically selected. -
To import data from the file, you must map the fields in the CSV file to properties on the
Person
node. Click theMap from file
button. -
You can then choose which fields from the CSV file to map to the node properties. Click
Select all
to map all the fields andConfirm
.The fields from the CSV file will be added as properties to the
Person
node.
Data importer creates a Name
for each property and assigns a Type
based on the data in the file. The Column
refers to the field in the CSV file.
Update Properties
You can modify the properties before running the import.
It is good practice to check the data types and, depending on the source data, update the names of the properties.
You should update some of the property names to be more concise:
From | To |
---|---|
|
|
|
|
|
|
|
|
You can rename the properties by selecting the property name and typing the new name.
You must also assign a property as the node’s unique identifier (ID).
You can use the tmdbId
as the unique identifier for the Person
nodes.
To set the unique identifier, click the key icon next to the tmdbId
property.
Once the properties are updated and a unique ID set, you can run the import and create the Person
nodes from data in the persons.csv
file.
Run the import
Click the Run import
button to create the Person
nodes.
Using your configuration, Data importer will load the data from the CSV file and create the data in the Neo4j database.
Once complete, you will see an import summary, including counts of the nodes created and properties set.
Click Close
to return to Data Importer.
You can modify the import configuration and rerun the import multiple times.
View the data
You can view the data in Neo4j using this Cypher, which returns the first 25 Person
nodes:
MATCH (p:Person) RETURN p LIMIT 25
Backup your work
Data Importer saves changes automatically, but you can download your import model and data by selecting the Download model (with data)
option from the menu …
.
You can restore your model using the Open model (with data)
option and selecting the downloaded file.
Need to download a working solution?
This Data Importer model, person-import.zip, contains a working solution for this exercise.
Download the model and open it using the Open model (with data) button
in the …
menu.
Note that this will replace your existing model.
Check Your Understanding
Creating Nodes with Data Importer
What must you do to create nodes using Data Importer? (Select all that apply)
-
✓ Upload a source file
-
✓ Create a node label
-
✓ Set a unique identifier for each node
-
❏ Update at least one property name
Hint
You can modify a node’s property names, although it isn’t mandatory.
Solution
To create nodes using Data Importer, you must:
-
Upload a source file
-
Create a node label
-
Set a unique identifier for each node.
You don’t have to update any property names.
Summary
In this lesson, you learned to import nodes from a CSV file using Data Importer.
In the next lesson, you will learn about the options for setting properties and data types.