Hi,
I have two .csv files contaning information about the nodes and edges I want to import. The node .csv has columns "id, name" where is an integer and name is a string. The edge .csv has columns "A_id, B_id, type", where "A_id" is the id of the source node for the edge and B_id is the id for the connected node and "type" for the relationship. The trouble is I only need one edge connecting two nodes where the direction doesn't matter, but each edge has a duplicate that only transposes A_id and B_id. This creates an additional relationship connecting two nodes in the opposite direction.
A_ID, B_ID
1 , 2
1 , 3
1 , 4
2 , 1
2 , 5
4 , 1
How do I load the edges while discarding the duplicates? I'm using the following query:
:auto LOAD CSV WITH HEADERS FROM "file:///edges.csv" AS row
CALL {
WITH row
MATCH (a:Company {id: toInteger(row.A_id)}), (b:Company {id: toInteger(row.B_id)})
CREATE (a)-[e:COMPETES_WITH {role: row.TYPE}]->(b)
} IN TRANSACTIONS of 2 ROWS