Hi
We've created nodes such as p:Person for around 50 persons in a CSV file and what we currently want is to split up the property of lets say Company to create their own nodes for this, and make relationships between.
The current dataset (CSV) looks like:
First Name,Last Name,Email Address,Company,Position,Connected On
Kasper,Knudsen,,ABBA The Museum,Customer Service,06 May 2020
Casper,Knudson,,Zaplify,Co-Founder and CEO,21 Mar 2020
and we are executing with:
await session.run("MATCH (n) DETACH DELETE n")
await session.run("LOAD CSV WITH HEADERS FROM 'file:///Users/kasperknudsen/test/api/src/uploads/Connections.csv' AS csvLine CREATE(p:Person{emailid:csvLine.`Email Address`}) Set p.firstName=csvLine.`First Name`,p.lastName=csvLine.`Last Name`,p.company=csvLine.Company,p.position=csvLine.Position,p.connectedOn=csvLine.`Connected On`");
TLDR: So I guess we want to split up some properties and create company as their own nodes. The relationships should be between company, position and person to begin with, with relations such as: Company -> Position -> Person
Hi @intouch_vivek,
-
Well I am creating p:Person and actually created c:Company aswell now (for all companies as properties), and made relationships now so that is quite good.
-
Well problem right now is that I still have duplicates (like relationships between person - company both ways + themselves..) so working on getting rid with those as of current.
-
Ah yea I know very few has a email connected so will change that. What is shown is a small part of the dataset.
The updated code:
await session.run("MATCH (n) DETACH DELETE n")
await session.run("CREATE (you:Person {name:'You'})")
await session.run("LOAD CSV WITH HEADERS FROM 'file:///Users/kasperknudsen/test/api/src/uploads/Connections.csv' AS csvLine CREATE(p:Person{emailid:csvLine.`Email Address`}) Set p.firstName=csvLine.`First Name`,p.lastName=csvLine.`Last Name`,p.company=csvLine.Company,p.position=csvLine.Position,p.connectedOn=csvLine.`Connected On`");
await session.run("LOAD CSV WITH HEADERS FROM 'file:///Users/kasperknudsen/test/api/src/uploads/Connections.csv' AS row CREATE(c:Company) Set c.company=row.Company")
await session.run("MATCH (c), (p) WHERE c.company=p.company MERGE (c)-[r:WORKSAT]->(p)")
await session.run("match (c)-[r]->(p) with c,p,type(r) as typ, tail(collect(r)) as coll foreach(x in coll | delete x)")
Hey @kasperknudz,
I did not understand the Model.
And by seeing your code I suspect things are not in place.
Either explain the model and requirement or share your skype id we can discuss on the same
Hi @intouch_vivek
Add kappanskyper on Skype, and thanks a lot for your efforts with helping us on this project!
Will be busy today if you are wondering why I don't respond.
No worries, if you are occupied today, we will discuss tomorrow.
Hi @intouch_vivek
Can you add me on Skype if you are available or send me ur Skype-id?
Thanks, Kasper
My skype id is vksrivas_1978