The Data Import Process

In this lesson, you will learn the process of importing CSV data using Cypher.

Source data

When you import data into Neo4j, you typically start with a set of source files.

You may have exported this source data from:

  • Relational databases

  • Web APIs

  • Public data directories

  • BI tools

  • Speadsheets (e.g. Excel or Google Sheets)

Export to CSV

Most data systems will have an option for exporting data to CSV files as it is a common format for data exchange.

The data in the source files may not be in the format needed for your graph data model:

  • The source files could contain more data than you need.

  • There may not be a 1-1 mapping of the data in a CSV file to a node or relationship.

  • The data types might not map directly onto those supported in Neo4j.

Likely, you will need to transform the data before or during the import.

Create a graph

Before you start the import process, you should:

  1. Understand the data in the source CSV files.

  2. Inspect and clean (if necessary) the data in the source data files.

  3. Understand the graph data model you will be implementing during the import.

Before you import data into Neo4j, there is no data structure, only the database itself - as you import data, you create the graph data model.

Once you have the source data and a graph data model, you can create the graph by importing the data.

Data mapping

You may find it useful to create a mapping document that shows how the source data maps to the graph data model.

The import involves creating Cypher code to:

  • Read the source data.

  • Transform the data as needed.

  • Create nodes, relationships, and properties to create the graph.

Creating an import process will likely require multiple iterations as you build, test, and refactor.

Check Your Understanding

Data model

True or False - A data structure for your graph exists in Neo4j before you import the data.

  • ❏ True

  • ✓ False

Hint

Before you import data into Neo4j the database is completely empty.

Solution

The statement is False - before you import data into Neo4j, there is no data structure, only the database itself - as you import data, you create the graph data model.

Summary

In this lesson, you learned about the process of importing CSV data into Neo4j using Cypher.

In the next lesson, you will learn about the CSV data format.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?