LOAD 2 CSV gives an error of Syntax Error "WITH is required between MERGE and LOAD CSV"

This code gives an error of below. How to solve it ?

Error:
Neo.ClientError.Statement.SyntaxError

WITH is required between MERGE and LOAD CSV (line 10, column 1 (offset: 295))
"MERGE (p:Person{Name:line.Name})"
^

Code:
LOAD CSV WITH HEADERS
FROM 'file:///GeneralInfo.csv'
AS line
MATCH (c:Cource{CourceName:line.CourceName}),(g:GeneralInfo{Gid:line.Gid})
MERGE (g)-[:BELONG]->(c)
LOAD CSV WITH HEADERS
FROM 'file:///Person.csv'
AS line
MERGE (p:Person{Name:line.Name,Height:line.Height,Weight:line.Weight})
RETURN p,c,g

Hi @kuwadat,

Welcome to the community!!

You are trying to run multiple statements at a time.
Either try one at time or check "Enable multi statement query editor" in the Neo4j browser setting and separate them via semi colon as below. Also since they are two statement u cannot return p,c,g in single line

LOAD CSV WITH HEADERS
FROM 'file:///GeneralInfo.csv'
AS line
MATCH (c:Cource{CourceName:line.CourceName}),(g:GeneralInfo{Gid:line.Gid})
MERGE (g)-[:BELONG]->(c)
Return g,c

LOAD CSV WITH HEADERS
FROM 'file:///Person.csv'
AS line
MERGE (p:Person{Name:line.Name,Height:line.Height,Weight:line.Weight})
RETURN p

2 Likes

Thank you very much !!