CSV NULL error

I am trying to make a word-pair frequency query
I'm getting this error:
Neo.ClientError.Statement.SemanticError: Cannot merge node using null property value

I tried to fix it with
where not text.content is null

But then I get a syntax error

Here is my code:

USING PERIODIC COMMIT
LOAD CSV FROM "file:///check.csv" AS text
FIELDTERMINATOR ' '
UNWIND range(0,size(text)-2) AS i
MERGE (w1:Word)
	where not text.content is null
		ON CREATE SET w1.content=text[i]
		ON CREATE SET w1.count=1
	    ON MATCH SET w1.count=w1.count+1
MERGE (w2:Word)
	where not text.content is null
		ON CREATE SET w2.content=text[i+1]
		ON CREATE SET w2.count=1
	    ON MATCH SET w2.count=w2.count+1
MERGE (w1)-[r:NEXT]->(w2)
	ON CREATE SET r.count=1
    ON MATCH SET r.count=r.count+1
RETURN text

You need to use this syntax: MERGE (node:Label {key: value}) where key-value are your merge attributes that identify your nodes uniquely.

So in your case:

USING PERIODIC COMMIT
LOAD CSV FROM "file:///check.csv" AS text
FIELDTERMINATOR ' '
WITH text where not text.content is null
UNWIND range(0,size(text)-2) AS i
MERGE (w1:Word {content:text[i]})
		ON CREATE SET w1.count=1
   	        ON MATCH SET w1.count=w1.count+1
MERGE (w2:Word {content:text[i+1]})
		ON CREATE SET w2.count=1
    	        ON MATCH SET w2.count=w2.count+1
MERGE (w1)-[r:NEXT]->(w2)
	ON CREATE SET r.count=1
        ON MATCH SET r.count=r.count+1
RETURN text
2 Likes

i had tried with above code with my data set ,but i am facing this error can you please tell me the solution.
.null

Can you put the CSV file (with dummy values if it's sensitive data) somewhere so that I can try to reproduce it?

Perhaps you have certain entries where your row has fewer entries?

That worked, thank you!

1 Like