What is the Neo4j Data Importer?
Neo4j Data Importer is a graph app the allows you to import CSV files from your local system into the graph. With this graph app, you can examine the CSV file headers, and map them to nodes and relationships in a Neo4j graph. You connect to a running Neo4j DBMS to perform the import. The benefit of the Data Importer is that you need not know Cypher to load the data.
It is useful for loading small to medium CSV files that contain fewer that 1M rows.
Data that is imported into the graph can be interpreted as string, integer, float, datetime, or boolean data. If a field in a row needs to be stored in the graph as a list, it will be by default stored in the graph as a string and you will need to post-process the graph after the import. You will learn about this later in this course.
For this course, we use Neo4j Data Importer Version 0.7.0. This version of Neo4j Data Importer can be found here
Neo4j Data Importer Versions
Neo4j Data Importer Early Access is evolving rapidly.
Here are the URLs for launching the latest version of Neo4j Data Importer:
-
For connecting to a remote DBMS: https://data-importer.neo4j.io/?acceptTerms=true
-
For connecting to a remote DBMS: https://data-importer.graphapp.io/?acceptTerms=true
-
For connecting to local DBMS: http://data-importer.graphapp.io/?acceptTerms=true
In this course we use the neo4j.io Version 0.7.0 of Neo4j Data Importer since we use a Neo4j Sandbox instance for this course.
While the essence of the product remains the same, the UI may look different as the versions of the product evolve.
Requirements for using the Data Importer
-
You must use CSV files for import.
-
CSV files must reside on your local system so you can load them into the graph app.
-
CSV data must be clean (you learned this in an earlier lesson).
-
IDs must be unique for all nodes you will be creating.
-
The CSV file must have headers.
-
The DBMS must be started.
Steps for using the Data Importer
Before you do the import, you should have a starting idea of how your graph data model will be implemented. The UI for the Data Importer uses the same UI elements that are used in the Arrows app.
Step 1: Placing the CSV file(s) on your local system and ensure they have headers and are clean.
You will examine the files and make sure they have headers and are "clean", as you learned about in an earlier lesson.
Step 2: Opening the Neo4j Data Importer
In the next Challenge, you will open the Data Importer app from any Web browser using this URL: https://data-importer.neo4j.io/versions/0.7.0/?acceptTerms=true
![Neo4j Data Importer](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/data-importer.png)
When you open Data Importer, it asks you to connect to a running DBMS. This is where you provide the WebSocket Bolt URL and password for the sandbox instance used for this course.
![Connect to Sandbox](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/connect.png)
Step 3: Loading the CSV files on your local system into the graph app
You will either drag the CSV files into the Files pane on the left or use Browse to select them as shown here.
![Select CSV files](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/select-files.png)
Here is what you will see after you have selected the files for import:
![Selected CSV files](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/files-selected.png)
Step 4: Examining the CSV header names used in the CSV files
You will examine the first rows of each CSV file to determine:
-
Files to be used to create nodes.
-
Files to be used to create relationships.
-
How IDs are used to uniquely identify data.
Step 5: Adding a node
You will:
-
Add the node in the UI by clicking the Add Node icon.
![Click add node](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/add-node.png)
-
Specify a label for the node in the Mapping Details pane.
![Add the node label](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/add-person-label.png)
-
Select the CSV file to use in the Mapping Details pane.
![Select CSV file](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/select-csv-file.png)
Step 6: Defining mapping details for the node
You will:
-
Specify properties for the node (select Add from File where we select all fields).
![Add all properties from file](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/add-all-properties.png)
-
If you want a property to use a different name or type, edit the property.
![Modify property name](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/modify-property-name.png)
-
Specify the unique ID property for the node.
![Select unique ID](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/select-unique-id.png)
After you have mapped properties, they will be marked in green in the left panel:
![Person properties mapped](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/person-properties-mapped.png)
Step 7: Creating the relationships between nodes
You will:
-
Add the relationship in the UI by dragging the edge of a node to itself or another node.
![Add relationship](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/add-relationship.png)
-
Specify a type for the relationship in the Mapping Details pane.
![Add DIRECTED label](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/add-DIRECTED-label.png)
-
Select the CSV file to use in the Mapping Details pane.
![Add DIRECTED file](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/add-DIRECTED-file.png)
Step 8: Defining the mapping details for the relationship
You will:
-
In the Mapping Details pane, specify the from and to unique property IDs to use.
![Select ID mapping](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/DIRECTED-IDs.png)
-
If applicable, add properties for the relationship from the file (optional).
-
Modify the names or types of the properties (if required by you data model).
-
Confirm CSV in the left panel is all set for import.
![Confirm relationship mapping done](https://raw.githubusercontent.com/neo4j-graphacademy/importing-data/main/modules/2-using-data-importer/lessons/1-overview/images/confirm-DIRECTED-done.png)
Step 9: Performing the import
You will:
-
Import the data.
-
View the import results.
Step 10: Viewing the imported data in Neo4j Browser
You will view the imported data in Neo4j Browser.
If you have de-normalized data, you will need to perform a multi-pass import. That is, you cannot create multiple nodes and relationship types from a single CSV file.
Other features of the Neo4j Data Importer
You can import or export your mappings to a JSON file or to a ZIP file if you also want to include the CSV files.
Check your understanding
1. Neo4j Data Importer
Select the key features of the Neo4j Data Importer:
-
✓ No need to use Cypher to perform the import.
-
✓ Create nodes with a given label from a single CSV file’s mapping.
-
✓ Create relationships with a given type from a single CSV file’s mapping.
-
❏ In the app, you can extract from a live RDBMS and import into a Neo4j graph.
Hint
Neo4j Data Importer relies on CSV files for import and you need not use Cypher for performing the import.
Solution
Here are the key features of the Neo4j Data Importer:
-
No need to use Cypher to perform the import.
-
Create nodes with a given label from a single CSV file’s mapping.
-
Create relationships with a given type from a single CSV file’s mapping.
2. Files used by the Data Importer
What statements below describes the files used by the Data Importer?
-
❏ The files must be in a location in a public S3 bucket.
-
✓ The files must reside your local system.
-
✓ The files must be in CSV format.
-
✓ The first row of the files must contain headers.
Hint
These are three, minimal requirements for files when using the Data Importer.
Solution
Files used by the Data Importer have these requirements:
-
The files must reside your local system.
-
The files must be in CSV format.
-
The first row of the files must contain headers.
Summary
In this lesson, you learned what the Neo4j Data Importer is and the steps for using it. In the next challenge, you will use the Data Importer to import CSV data.