Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-03-2022 12:48 AM
Hi
I have a dataset consisting of two csv files.
The first csv is a list of codes and their description. Example:
1, A
2, B
3, C
The second CSV, contains a list of related codes. Example
1, 2
1, 1
2, 3
The code may be related to themselves or to other codes. Some of the codes may not have any relations.
I have loaded the first csv and created nodes for the code and description
How can I load the second csv to create the relationships between the nodes ?
Thanks
Br
Praveen
Solved! Go to Solution.
05-03-2022 01:40 AM
I am able to get the relationship with the below queries:
LOAD CSV from 'file:///AllCodes.csv' as row
FIELDTERMINATOR ';'
with toInteger(row[0]) as codeID, row[1] as CodeDescription
MERGE (m:CodeList {codeID: codeID, CodeDescription: CodeDescription});
LOAD CSV from 'file:///CodeRelations.csv' as row
FIELDTERMINATOR ';'
with toInteger(row[0]) as leftID, toInteger(row[2]) as rightID
MATCH (code1), (code2)
WHERE code1.codeID = leftID AND code2.codeID = rightID
CREATE (code1)-[:PT]->(code2);
If there is any better/faster way to do it. Please do let me know.
Thanks
05-03-2022 01:40 AM
I am able to get the relationship with the below queries:
LOAD CSV from 'file:///AllCodes.csv' as row
FIELDTERMINATOR ';'
with toInteger(row[0]) as codeID, row[1] as CodeDescription
MERGE (m:CodeList {codeID: codeID, CodeDescription: CodeDescription});
LOAD CSV from 'file:///CodeRelations.csv' as row
FIELDTERMINATOR ';'
with toInteger(row[0]) as leftID, toInteger(row[2]) as rightID
MATCH (code1), (code2)
WHERE code1.codeID = leftID AND code2.codeID = rightID
CREATE (code1)-[:PT]->(code2);
If there is any better/faster way to do it. Please do let me know.
Thanks
All the sessions of the conference are now available online