Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-14-2020 04:19 AM
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
05-14-2020 06:54 AM
Hi @kasperknudz,
Are you saying Person node already there in the DB and you to split it's property to distinct node of label Company ?
Or you need to insert new dataset with Labels Person , Company and Position? If this is the case what is the relationship between these nodes? What will be properties of Nodes and relationships?
Your data set has no email address and you are using that in the Create Statement
05-15-2020 12:16 AM
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)")
05-15-2020 05:39 AM
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
05-15-2020 05:46 AM
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.
05-15-2020 05:49 AM
No worries, if you are occupied today, we will discuss tomorrow.
05-18-2020 02:42 AM
Can you add me on Skype if you are available or send me ur Skype-id?
Thanks, Kasper
05-18-2020 05:06 AM
My skype id is vksrivas_1978
All the sessions of the conference are now available online