0

I have already created the nodes before and I would like to use the relationships file used some time ago during a batch- import, to create relationships using the load CSV method.

This is my relationships CSV file:

enter image description here

ErEcTuS
  • 777
  • 1
  • 14
  • 33

1 Answers1

2

You'll need to use LOAD CSV for this (USING PERIODIC COMMIT), although you'll need to watch out for spaces in both the headers (if you use them) and your fields. trim() may help in your fields.

The headers shouldn't have : in them if at all possible.

The biggest obstacle will be dynamically using the type of the relationship from the csv. Currently Cypher does not deal with relationship types dynamically, you'll need an alternate approach. Install APOC Procedures and use apoc.create.relationship() to handle that.

InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
  • Thanks Falcon for the reply and the suggestions. Indeed, The files headers cannot be used in both batch import and load csv. – ErEcTuS Apr 15 '18 at 23:55
  • I dealt with exactly this issue (creating dynamic relationships from a CSV file and LOAD CSV) here: https://stackoverflow.com/questions/49682338/creating-a-metabolic-pathway-in-neo4j/49805022. I ended up using a `CALL apoc.merge.relationship(s, row.relation, {}, {}, t) YIELD rel` APOC procedure. – Victoria Stuart Apr 16 '18 at 16:06