Use APOC Procedure for row when using LOAD CSV

Hello, I'm trying to load a CSV and one of my rows requires calling an APOC procedure. However, I'm getting an error.

My code:

LOAD CSV WITH HEADERS FROM '(url here)' AS row 
MERGE (Customer:Customer {name: row.CustomerId, lat: CALL { CALL apoc.spatial.geocode("1600 Pennsylvania Avenue") YIELD latitude RETURN latitude } RETURN latitude limit 1;})

The error I'm getting:

Neo.ClientError.Statement.SyntaxError: Invalid input 'apoc': expected "," or "}" (line 2, column 66 (offset: 156))
"MERGE (Customer:Customer {name: row.CustomerId, lat: CALL { CALL apoc.spatial.geocode("1600 Pennsylvania Avenue") YIELD latitude RETURN latitude } RETURN latitude limit 1"

Is there a way to call an APOC procedure to yield data for a row?

I'm able to call the procedure outside of the LOAD CSV query.

Thank you!

Hello @henry007,

You should call the apoc statement before the merge and define it as a variable. This query should work:

LOAD CSV WITH HEADERS FROM '(url here)' AS row
CALL apoc.spatial.geocode("1600 Pennsylvania Avenue") YIELD latitude
MERGE (Customer:Customer {name: row.CustomerId, lat: latitude})
1 Like

Thank you very much!