Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-03-2021 12:01 PM
Hi everyone,
I try to load csv file into the neo4j.
My Query is:
:auto USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM "file:///C:/mesh_network.csv" AS line
FIELDTERMINATOR ';'
Merge(n:Mesh {name:line.mesh,frequency:toInteger(line.frequency1)})
Merge(m:Mesh {name:line.mesh,frequency:toInteger(line.frequency2)})
Merge (n)-[:SEEN {weight:toInteger(line.weight)}]-(m)
Before loading data I set node should be unique based on node name.
However, it gives this error.
Solved! Go to Solution.
07-04-2021 01:43 AM
Hi , i checked number of unique mesh for both mesh1 and mesh2. Then i realized that the number of mesh2 more than number of mesh1. Then i picked up mesh2 as a first node and mesh1 for second node then it worked even wiht unique constraint.
Thank you again
07-03-2021 01:13 PM
Hi @dilmacfatih
Did you create CONSTRAINT like this?
CREATE CONSTRAINT constraint_name ON (mesh:Mesh) ASSERT mesh.name IS UNIQUE
Please SHOW CONSTRAINTS.
SHOW CONSTRAINTS
And DROP it.
DROP CONSTRAINT constraint_name
07-03-2021 01:59 PM
Thank you koji for your answer. Before loading the data i created constraint as you mentioned.
Without constraint it works. However i rellay want to single node for each mesh. That is why i created unique constraint. Otherwise the graph becames disconnected likte this.
Instead of 2 mesh1 in the graph there should be only 1.
mesh1 freq1 mesh2 freq2 weight
adult;15320;tranexamic acid;7;1
adult;15320;mediation analysis;7;3
adult;15320;hospitals special;59;22
adult;15320;vitamin d;283;37
adult;15320;bathroom equipment;10;2
adult;15320;otitis externa;1;1
adult;15320;health occupations;30;1
adult;15320;mediastinal emphysema;63;1
this is a pice of my dataset
Thank you again.
07-03-2021 05:55 PM
Hi @dilmacfatih
If your Mesh is unique by name, and you need Freq data, how about the following design?
07-04-2021 01:43 AM
Hi , i checked number of unique mesh for both mesh1 and mesh2. Then i realized that the number of mesh2 more than number of mesh1. Then i picked up mesh2 as a first node and mesh1 for second node then it worked even wiht unique constraint.
Thank you again
All the sessions of the conference are now available online