cancel
Showing results for 
Search instead for 
Did you mean: 

Export neo4j data to json file

beginner
Node Link

I have neo4j database with 20 nodes, but there is only 2 label,x and y, now if I export data like below

MATCH (n) RETURN n

after the result of the above command, just used the option Export JSON and saved the JSON file

everynode comes as single element in the list between square brackets in JSON file, but I want it all 20 nodes as separate in the same JSON file. when I load it and print the results, it prints in the single line as

code

	with open('./data/hello.json') as df:
		df1= json.load(df)
		print(df1)

Actual Output

[{'n': {'identity': 50, 'labels': ['x'], 'properties': {'name': 'a', 'place': 'b', 'id': 001}}}, {'n': {'identity': 51, 'labels': ['x'], 'properties': {'name': 'c', 'place': 'd', 'id': 002}}},....]

Expected Output

{'n': {'identity': 50, 'labels': ['x'], 'properties': {'name': 'a', 'place': 'b', 'id': 001}}}, 
{'n': {'identity': 51, 'labels': ['x'], 'properties': {'name': 'c', 'place': 'd', 'id': 002}}},
.
.
.
so on
1 REPLY 1

tarendran_vivek
Graph Voyager

Hi @beginner,

If you want to transfer your neo4j database, then you can use these commands
Make you sure you enable export file and import file in your configurations

apoc.import.file.enabled=true
apoc.export.file.enabled=true

Export the database

CALL apoc.export.graphml.all("test.graphml", {})

Import the database

CALL apoc.import.graphml("test.graphml",{readLabels:true})

You can read up more here

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.