📤 Exporting Data from Neo4j
1. Export to CSV
You can export query results as CSV.
Example
👉 In Neo4j Browser, you can click “Download CSV”.
Or in Cypher Shell:
📄 export.csv
2. Export to JSON
JSON is handy for APIs or app integration.
Using APOC plugin:
📄 export.json
3. Exporting Whole Database
-
CSV:
-
JSON:
4. Other Options
-
apoc.export.cypher.*
→ export Cypher scripts (for re-import). -
apoc.export.graphml.*
→ export GraphML (XML format). -
In Neo4j Bloom or Browser, you can visually download query results as CSV.
✅ Summary
-
For small queries → just
RETURN
and download. -
For full database or structured exports → use APOC export functions.
-
Choose CSV for spreadsheets/SQL imports, JSON for APIs/web apps.
APOC (Awesome Procedures On Cypher) is like a Swiss army knife for Neo4j 🛠️.
When it comes to ETL (Extract, Transform, Load), APOC is the go-to extension for importing, transforming, and exporting data.
⚡ APOC for ETL in Neo4j
1. Extract (Getting data in)
APOC provides procedures to read data from external sources (CSV, JSON, XML, databases, APIs).
Examples
-
From CSV
-
From JSON (API or file)
-
From JDBC (RDBMS)
2. Transform (Clean / reshape data)
APOC helps in data transformation before saving into graph.
Examples
-
String functions
-
Splitting and trimming
-
Mapping JSON fields to nodes
3. Load (Insert into Neo4j)
After transforming, load data into nodes and relationships.
Example – Import CSV into graph
users.csv
Cypher:
Example – Import JSON with relationships
Cypher:
4. Export (Send data out)
-
CSV:
-
JSON:
-
To relational DB:
✅ Summary
-
Extract →
apoc.load.csv/json/xml/jdbc
-
Transform →
apoc.text.*
,apoc.map.*
, FOREACH, Cypher functions -
Load →
MERGE
nodes/relationships -
Export →
apoc.export.csv/json/jdbc/cypher/graphml
👉 In short: APOC makes Neo4j ETL pipelines super flexible, connecting graphs to almost any system
Comments
Post a Comment