Pleasee, help! How create relationships on people from one file

i am new to this. I have a csv file with 48 thousand lines about people who have published articles along with other people. How can I create relationships between these people without repetition?

I have the id of their joint publication, the id of these people and their names. I want to create an offshoot using their collaborative post id. But I'm doing it wrong :( I create relationships for myself

load csv with headers from 'file:///1_.csv' as row with row where row.FIO is not null
Merge (fio:FIO{Name:row.FIO})
merge (fio_2:FIO{Soau:row.FIO})
Merge (fio)-[:WITH{idw:row.IDWORK}]->(fio_2)

|IDWORK|ID_PERSON|NAME|
|202 |43342 |S.Smith|
|202 |43982 |T.Lee|
|202 |44203 |V.Neiman
|203 |43982 |S.Solovey|
|203 |43980 |E.Royak|
|862 |43989 |B.Lemeshko|
|862 |43979 |N.Empty|
|17725 |43989 |B.Lemeshko|
|17725 |10000270 |E.Mirkin|

Where is 'FIO' in your data file? I don't see a column for it.

Can you also post the data and query that creates the publications?

Ops, mistake
there should be NAME
load csv with headers from 'file:///1_.csv' as row with row where row.NAME is not null
Merge (fio:NAME{Name:row.NAME})
merge (fio_2:NAME{Soau:row.NAME})
Merge (fio)-[:WITH{idw:row.IDWORK}]->(fio_2)

relationships create themselves

What do you mean "without duplicates"? What is getting duplicated?

due to the repeated names of the authors, I thought that new nodes with the same names would be created

I am sorry.. I am having a difficult time understanding what is and what is not working.

I you thought you would get one node with the person's name in the below query, that will not happen because in one case you are looking for the property 'Name' to equal row.NAME and in the next it is the property 'Soau' equal to row.NAME. As such, you will get two nodes with the same name, but in different attributes.

load csv with headers from 'file:///1_.csv' as row with row where row.NAME is not null
Merge (fio:NAME{Name:row.NAME})
merge (fio_2:NAME{Soau:row.NAME})
Merge (fio)-[:WITH{idw:row.IDWORK}]->(fio_2)

From what I read, it looks like you have people writing articles, possibly together, and you want to link the authors to these articles. It seems you are linking them with a relationships, where the article's ID is a property of the relationships. This makes the relationships equivalent to the article. This is not the correct way of modeling this data. Relationships are for modeling relationships between two entities and nodes are for modeling entities. In your case, an article is an entity. I suggest you have 'Author' or 'People' nodes and you have 'Article' nodes, and you link the articles to their author nodes with a 'HAS_AUTHOR' relationship for each author.

Does this accurately represent your case?

Yes that's right!
I want to link article authors via IDWORK since it's shared between authors, but I can't figure out how to do it.
I wanted to do it like (author)-[ :WITH {idwork} ]-(author)

That is, use the article identifier (IDWORK) as a node and associate it with authors (people) and name the relationship, for example, "writes with"

1 Like

Thanks! I did it:)

1 Like