cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Is it possible to get only one node "gary" by using header name?

Screenshot from 2023-02-08 18-01-36.png

 

6 REPLIES 6

Sorry, I don’t understand the question. Will you please provide more detail? 

the csv file contain duplicate nodes and null values . a and b are persons and there relation is c. I'm trying to get a o/p without duplication and null values and along with that i need a single node 'Gary' which comes under the header B.   here is the o/p -> Screenshot from 2023-02-09 11-49-14.png

 now i need one more node  which is "Gary".
Screenshot from 2023-02-08 18-01-36.png

 

i used this query,
i need one more node "gary " with its property "
e"
load
csv with headers from "file:///newtask.csv" as row
WITH row WHERE NOT row.E IS null
WITH row WHERE NOT row.A IS null
MERGE(p1:person{firstName:row.A,age:row.E})
MERGE(p2:person{firstName:row.B})
WITH p1, p2, row
CALL apoc.create.relationship(p1, row.C,{number:row.D}, p2) YIELD rel
RETURN rel







You filtered that row out, since A is null. What do you want to do with B, since A is null and the relationship can’t be created between A and B 

Try this:
load csv with headers from "file:///newtask.csv" as row
WITH row WHERE NOT row.E IS null

CALL 

{
	WITH row
	WITH row WHERE NOT row.A IS null
	MERGE(p1:Person{firstName:row.A,age:row.E})
	return p1, "yes" as flg

UNION

	WITH row
	WITH row WHERE row.A IS null and row.B is not null
	MERGE(p1:Person{firstName:row.B,age:row.E})
	return p1, "no" as flg
}

WITH row, p1, flg 
MERGE(p2:Person{firstName:row.B})

WITH row, p2, p1, flg where flg = "yes"
CALL apoc.create.relationship(p1, row.C,{number:row.D}, p2) YIELD rel
RETURN rel

thank you

return p1, "yes" as flg

can you please explain me this part, it is confusing