0Pricing
Neo4j Graph Database Fundamentals · Lektion

Daten importieren und exportieren

Entdecken Sie verschiedene Methoden, um Daten aus externen Quellen in Neo4j zu laden und Graphdaten für andere Zwecke zu exportieren.

Daten importieren und exportieren ist eine kostenlose Neo4j Graph Database Fundamentals-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Neo4j Graph Database Fundamentals-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Neo4j Graph Database Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Moving Data In & Out

In this lesson, we'll explore how to get data into your Neo4j graph database and how to extract it for other uses. This is crucial for integrating Neo4j with existing systems, migrating data, or preparing it for analysis.

Importing Data: An Overview

Bringing external data into Neo4j is a common task. There are several powerful methods:

  • LOAD CSV: For structured data from CSV files.
  • APOC Procedures: For more complex formats like JSON, XML, or data from external databases.
  • Connectors & Drivers: Programmatic import via application code.

We'll focus on the first two methods.

LOAD CSV: The Basics

The LOAD CSV Cypher clause is your go-to for importing data from CSV files. It lets you specify the file path, handle headers, and access each row's data.

Here's a basic structure to read a CSV and return its rows:

LOAD CSV WITH HEADERS FROM 'file:///users.csv' AS row
RETURN row;

Creating Nodes from CSV

Let's say you have a users.csv file with id,name,email columns. You can use LOAD CSV to create User nodes:

LOAD CSV WITH HEADERS FROM 'file:///users.csv' AS row
CREATE (:User {id: row.id, name: row.name, email: row.email});

Creating Relationships from CSV

You can also create relationships. If you have a follows.csv with followerId,followedId, you can connect existing User nodes:

  • We use MATCH to find the existing nodes.
  • CREATE then forms the relationship between them.
LOAD CSV WITH HEADERS FROM 'file:///follows.csv' AS row
MATCH (u1:User {id: row.followerId})
MATCH (u2:User {id: row.followedId})
CREATE (u1)-[:FOLLOWS]->(u2);

Beyond CSV: APOC for Import

For more complex import scenarios, such as JSON or XML files, or data from external databases, the APOC (Awesome Procedures On Cypher) library is invaluable. APOC extends Cypher with hundreds of new procedures and functions.

You'll need to install the APOC plugin for your Neo4j instance to use these features.

Importing JSON with APOC

If you have data in a JSON file, like products.json, you can use apoc.load.json to parse it. Each item in the JSON array can then be processed to create nodes and relationships.

CALL apoc.load.json('file:///products.json') YIELD value
CREATE (:Product {id: value.id, name: value.name, price: toFloat(value.price)});

Exporting Data: An Overview

Just as important as importing is exporting data from your graph. You might need to:

  • Generate reports.
  • Migrate data to another system.
  • Perform advanced analytics outside Neo4j.
  • Create backups.

We'll look at basic Cypher export and advanced APOC export.

Basic Export with Cypher

The simplest way to export data is using standard Cypher MATCH and RETURN statements. The results are displayed in the Neo4j Browser and can be copied or downloaded as CSV/JSON.

MATCH (u:User)-[:FOLLOWS]->(f:User)
RETURN u.name AS Follower, f.name AS Followed;

Advanced Export with APOC

APOC offers powerful procedures to export your graph data directly to files in various formats (CSV, JSON, GraphML, etc.). These are ideal for full graph exports or specific subgraphs.

For example, to export all nodes and relationships to a CSV file:

CALL apoc.export.csv.all('full_graph_export.csv', {});

Import/Export Challenge

You have a CSV file named books.csv with the columns isbn, title, author. You want to import this data into Neo4j, creating nodes with the label Book and properties for each column.

Recap: Data Movement Skills

You've learned essential skills for moving data in and out of Neo4j:

  • LOAD CSV is powerful for structured data.
  • APOC procedures extend capabilities for JSON, complex exports, and more.
  • Standard Cypher MATCH and RETURN allow simple data extraction.

Mastering these techniques is key for managing your graph data effectively!

Häufig gestellte Fragen

Ist die Lektion „Daten importieren und exportieren“ kostenlos?

Ja — der vollständige Text von „Daten importieren und exportieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Neo4j Graph Database Fundamentals-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Neo4j Graph Database Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Daten importieren und exportieren“?

Entdecken Sie verschiedene Methoden, um Daten aus externen Quellen in Neo4j zu laden und Graphdaten für andere Zwecke zu exportieren. Du übst Neo4j Graph Database Fundamentals mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Neo4j Graph Database Fundamentals zu starten?

Keine Vorkenntnisse erforderlich. Neo4j Graph Database Fundamentals auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „Daten importieren und exportieren“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Neo4j Graph Database Fundamentals-Lektion Code schreiben und ausführen?

Ja. Jede Neo4j Graph Database Fundamentals-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Neo4j Browser und Verwaltungstools
  2. Daten importieren und exportieren
  3. Strategien für Sicherung und Wiederherstellung
  4. Monitoring und Logging in Neo4j
← Zurück zu Neo4j Graph Database Fundamentals