Export Data
The COPY TO command enables direct export of query results to various file formats. Currently, CSV export is fully supported, with Parquet and DataFrame formats coming soon. This is useful for persisting the result of a query to be used in other systems or preserving query outputs for archival use.
Copy to CSV
The COPY TO clause can export query results to a CSV file and is used as follows:
COPY (MATCH (p:person) RETURN p.*) TO 'person.csv' (header=true);The CSV file consists of the following fields:
p.id|p.name|p.age
1|marko|29
2|vadas|27
4|josh|32
6|peter|35Complex types, such as vertices and edges, will be output in their JSON-formatted strings.
Available parameters are:
| Parameter | Description | Default |
|---|---|---|
HEADER | Whether to output a header row. | false |
DELIM or DELIMITER | Character that separates fields in the CSV. | | |
Another example is shown below.
COPY (MATCH (:person)-[e:knows]->(:person) RETURN e) TO 'person_knows_person.csv' (header=true);This outputs the following results to person_knows_person.csv:
e
{'_SRC': '0:0', '_DST': '0:1', '_LABEL': 'knows', 'weight': 0.500000}
{'_SRC': '0:0', '_DST': '0:2', '_LABEL': 'knows', 'weight': 1.000000}🔮 Coming Soon: Additional Export Formats
NeuG is expanding export capabilities to support more data formats:
- Parquet Export: High-performance columnar format for analytics and data science workflows
- DataFrame Integration: Direct export to pandas DataFrames and other data science tools
- Streaming Export: Efficient export of large result sets with memory optimization
These enhancements will provide seamless integration with modern data science and analytics pipelines.
🎯 Export Best Practices
- Large Result Sets: Use LIMIT clauses to avoid memory issues when exporting large datasets
- Data Types: Complex graph objects (nodes/edges) are exported as JSON strings for maximum compatibility
- File Paths: Ensure the target directory exists and is writable before running export commands