Data Importer

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:

  1. Connect to a Neo4j database

  2. Upload a CSV file

  3. Create a node

  4. Map properties from the CSV file to the node

  5. 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.

  1. Open the Import tab in Neo4j Workspace at https://workspace.neo4j.io.

  2. Select the Connect button from the connection menu to connect to your sandbox.

    The connect button in the data importer
  3. Enter the following details to connect to your Neo4j sandbox.

    Connection URL

    {sandbox-host}:{sandbox-boltPort}

    Username

    {sandbox-username}

    Password

    {sandbox-password}

    The connect dialog in the data importer
  4. 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 …​.

The clear all option in the data importer 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.

  1. Download the persons.csv file.

  2. Upload the persons.csv file to Data Importer using the Files panel.

    The files panel in data importer
  3. Once uploaded, the file and its contents will be displayed.

    The file contents in data importer

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.

  1. Add a new node label.

    The add node button in data importer
  2. Label the node as Person in the Definition panel.

  3. The persons.csv file should be automatically selected.

    The node label box in data importer
  4. To import data from the file, you must map the fields in the CSV file to properties on the Person node. Click the Map from file button.

    The Map from file highlighted
  5. You can then choose which fields from the CSV file to map to the node properties. Click Select all to map all the fields and Confirm.

    The map from file dialog showing the fields to map

    The fields from the CSV file will be added as properties to the Person node.

    The fields are added as properties to the Person node in the properties panel

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:

Update property names
From To

person_tmdbId

tmdbId

person_imdbId

imdbId

person_poster

poster

person_url

url

You can rename the properties by selecting the property name and typing the new name.

The property name being edited in the properties panel

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.

The key icon next to the movieId property in the properties panel

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.

The run import button in data importer

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.

The import summary in data importer

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:

cypher
MATCH (p:Person) RETURN p LIMIT 25
The results of the Cypher query showing a graph of 25 Movie nodes

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 …​.

The download model (with data) option in the data importer 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.

The Open model (with data) button highlighted 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.