This is my first time to use NEO4J with almost zero experience. I got error when run the following:
LOAD CSV WITH HEADERS FROM "file:///C:/sample3.csv" as line
MERGE (a:test2 {Name:line.ANI})
MERGE (b:test2 {Name:line.CUST})
MERGE (c:test2 {Name:line.ESN})
MERGE (d:test2 {Name:line.CUST2})
MERGE (a) -[:calls {test:line.L1}]-> (b)
MERGE (b) -[:esn {test:line.L2}]-> (c)
MERGE (c) -[:test_accounts {swap:line.L3 }]-> (d)
Neo.ClientError.Statement.SemanticError
Cannot merge node using null property value for Name
I know the reason is there are maybe NULL values in node d and L3.
I am not sure how to fix this to display the graph when node d and L3 do give you values.
you can have the LOAD CSV not parse the row given a condition, for example
LOAD CSV WITH HEADERS FROM "file:///C:/sample3.csv" as line
with line where line.L3 is not null
MERGE (a:test2 {Name:line.ANI})
MERGE (b:test2 {Name:line.CUST})
MERGE (c:test2 {Name:line.ESN})
MERGE (d:test2 {Name:line.CUST2})
MERGE (a) -[:calls {test:line.L1}]-> (b)
MERGE (b) -[:esn {test:line.L2}]-> (c)
MERGE (c) -[:test_accounts {swap:line.L3 }]-> (d)
Alternately, if only d and line.L3 can be null, only move them to the end, with the WHERE condition filtering rows out just before so all the other MERGEd nodes and relationships happen first:
LOAD CSV WITH HEADERS FROM "file:///C:/sample3.csv" as line
MERGE (a:test2 {Name:line.ANI})
MERGE (b:test2 {Name:line.CUST})
MERGE (c:test2 {Name:line.ESN})
MERGE (d:test2 {Name:line.CUST2})
MERGE (a) -[:calls {test:line.L1}]-> (b)
MERGE (b) -[:esn {test:line.L2}]-> (c)
WITH line
WHERE line.CUST2 IS NOT NULL
MERGE (d:test2 {Name:line.CUST2})
WITH line, d
WHERE line.L3 IS NOT NULL
MERGE (c) -[:test_accounts {swap:line.L3 }]-> (d)
Be aware there are Eager operators in the query plan here, you might want to consider multiple passes over the CSV to handle loading nodes first with CREATE or MERGE, one pass per column used for creation. This would only apply where the labels are the same (in your example case, all are :test2, driving the use of Eager).
Here's a blog entry on Eager operators in the query, what they are, what their consequences are, why they happen, and how to avoid them.