Node then Relationship

Hi All,

I would need help in creating my neo4j graph.

I have 2 files:
1 is persons.csv
id, person_name, Age
1,James Smith, 27
2,Mary Anne, 32
3,John Doe, 22

and i have a relationship file: social_connect.csv
id1, id2, interaction_count
1,2,34

I want to display all nodes with the actual names displayed, this includes a node for John doe with no connection

I have the below cypher to load the nodes:
load csv with headers from "file:///persons.csv" as csvline
create (p:Person {id:toInteger(csvline.id), name:csvline.person_name , age:csvline.Age})

I also have the below code which loads the relationships and create a network graph for it.
load csv with headers from "file:///social_connect.csv" as connection
merge (n: Person {Name: connection.id1})
merge (m: Person {Name: connection.id2})
merge (n) - [r:connect] ->(m)
ON CREATE SET r.weight = toInt(n.interaction_count)

But i would like to connect the two data and then show unconnected Persons.

Any help would be much appreciated. Thank you

Hi Juan,

Welcome to the community!!
Although your insertion is not good however if those are just to make us clear. In short if data is properly inserted in the DB then your required query can we as below.

MATCH a WHERE NOT (a)-[:connect]->()

Use MATCH (n:Person) RETURN n returns all Person connected and disconnected nodes. As Vivek pointed out, here is the change

load csv with headers from "file:///social_connect.csv" as connection
MATCH (n: Person {Name: connection.id1})
MATCH (m: Person {Name: connection.id2})
MERGE (n) - [:connect {weight: toInteger(n.interaction_count)}] ->(m)