Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-10-2020 01:01 PM
Exampel, CSV file with heders.
<
SourceComNetName;Relationship;TargetComNetName
Network A;is_part_of;Network B
Network C;is_composed_of;Network D
/>
Cypher:
<
LOAD CSV WITH HEADERS FROM 'file:///test.csv' as line
FIELDTERMINATOR ';'
MERGE (sComNetwork:ComNetwork {name: line.SourceComNetName
})
MERGE (tComNetwork:ComNetwork {name: line.TargetComNetName
})
MERGE (sComNetwork)-[:line.Relationship
]->(tComNetwork)
/>
The last line will generate an Error.
Error:
Invalid input '.': expected
"*"
"]"
"{"
"|"
"$" (line 5, column 27 (offset: 226))
"MERGE (sComNetwork)-[:line.Relationship
]->(tComNetwork)"
Way don't line.Relationship
get substituted with "is_part_of" and "is_composed_of"?
Is it possible to dynamicly use data from the CSV file to generate the folowing relationships?
(Network A)-[is_part_of]->(Network B)
(Network C)-[is_composed_of]->(Network D)
12-10-2020 02:03 PM
I think you can do:
MERGE (sComNetwork)-[:TEMPREL {RelationshipType: line.Relationship} ]->(tComNetwork)
and then later add the Relationship type based on the RelationshipType
property, and then delete the TEMPREL
label.
I don't know if there is a way to get Cypher to evaluation a value and make it the actual relationship.
12-10-2020 04:17 PM
Use APOC:
CALL apoc.create.relationship(sComNetwork, line.Relationship, {}, s) YIELD rel
REMOVE rel.noOp
REMOVE rel.noOp is dummy one as CALL statement must end with RETURN.
12-11-2020 03:54 AM
Tank you! This works OK for me.
All the sessions of the conference are now available online