What does importing data mean?
When you import data into Neo4j, you typically have a set of source files that were obtained from:
-
RDBMS
-
Web APIs
-
Public data directories
-
BI tools
-
Excel
The file types are typically CSV, JSON, XML, etc.
In this course you will learn how to import CSV data into Neo4j as nodes, relationships, and their properties.
Cypher has a built-in clause, LOAD CSV
for importing CSV files.
If you have a JSON or XML file, you must use the APOC library to import the data, but you can also import CSV with APOC.
And the Neo4j Data Importer enables you to import CSV data without writing any Cypher code.
The data in the source files may contain more data than what you need in your graph. There may not be a 1-1 mapping of the data in a CSV file to what you would use as a node in a graph data model. In addition, the data in the source files may represent data types that are not supported in Neo4j or specified in the data model you are implementing. Some data in the source files may need to be transformed into the appropriate types.
The types of data that you can store as properties in Neo4j include:
-
String
-
Long (integer values)
-
Double (decimal values)
-
Boolean
-
Date/Datetime
-
Point (spatial)
-
StringArray (comma-separated list of strings)
-
LongArray (comma-separated list of integer values)
-
DoubleArray (comma-separated list of decimal values)
After you understand the source data you have to work as well as the graph data model you will be implementing, you can import the data into Neo4j. There are two ways that you can import CSV data into Neo4j that you will learn in this course:
-
Using the Neo4j Data Importer.
-
Writing Cypher code to perform the import.
In both cases, the import involves reading the source data and using it to create nodes, relationships, and properties in the graph.
Requirements for importing CSV data
You must have one or more CSV files that represent the nodes and relationships that will be created in the graph. You must also have an existing Neo4j DBMS that is started. You typically start with a graph that has nothing in it.
In this course, you will not be creating the source data files for import, but you will be using files that have already been created for you.
Steps for preparing for importing data
Here are the steps you follow to prepare for importing data into Neo4j:
-
Understand the data in the source CSV files.
-
Inspect and clean (if necessary) the data in the source data files.
-
Create or understand the graph data model you will be implementing during the import.
Check your understanding
Importing data with a Cypher clause
What format of source data file does Cypher support out-of-the-box for importing?
-
❏ JSON
-
❏ XML
-
✓ CSV
-
❏ GraphML
Hint
There is only one type of source data file that is supported by a Cypher out of the box.
Solution
CSV files are supported out of the box in Cypher.
Summary
In this lesson, you learned what importing data into Neo4j means and the steps you must take before you import data into Neo4j. In the next lesson, you will learn how CSV source data may be organized.