Hi everyone!
I have recently gotten started with Neo4j (desktop, 1.4.5-x86_64) and struggle with making relationships between my nodes. I have the two following .csv files: one describing my nodes, the other describing their relationships.
Nodes.csv: A list of the nodes, single column
Node (header)
Node_1
Node_2
...
Node_n
I loaded and created these nodes. I want to describe their relationships using another .csv ("relationships.csv ") which looks like this:
Node_A|Node_B|Similarity (headers)
Node_k|Node_j| float
...
Where Node_k and Node_j can be any pair of nodes from the Nodes.csv table, and their similarity is a float in the third column.
I have tried the following:
LOAD CSV WITH HEADERS FROM "file:///relationships.csv" as row
MATCH (n1:Node{id:row.Node_A})
MATCH (n2:Node{id:row.Node_B})
CREATE (n1)-[:SimilarTo]->(n2);
but get (no changes, no records)
. I also tried tweaking a bit of this code getting inspired from similar posts but I got errors.
Moreover, I would like to display the float
value on the edges of each of my relationships (Similarity column) in the resulting graph.
i.e (Node1)--Similarity(Node_1,Node_2)->(Node2)
Edit
I have finally managed to get the edges I wanted (only using relationships.csv though) with this:
LOAD CSV WITH HEADERS FROM "file:///relationships.csv" as row MERGE(s:Sim{sim:row.Similarity})
MERGE(n1:Column{name:row.Node_A})
MERGE(n2:Column{name:row.Node_B})
CREATE (n1)-[:has_connection]->(n2)
I get the appropriate links in a graph but with "has_connection" on the edges. How can I display the corresponding value for the pair (the third column in the relationships.csv file) in place of "has_connection" ?
Any help would be much appreciated, thanks!