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.

Syntax error around Cypher comments

rmasrani
Node Clone

Dear Community.

I am using the latest installation + the desktop browser. I am loading up a number of CSV files which is working great - except lately I am getting syntax errors when I insert comments within the Cypher script. Here is the offending script:

LOAD CSV FROM $customerSystem + $prod + "ENTRYID_PROGRAMNAME_TASKTYPE.TXT" as row FIELDTERMINATOR '\t'
WITH row WHERE row[2] <> "4" and row[0] is not null and row[1] is not null
MERGE (t:TRAN {label: row[0]})
MERGE (p:PROG {label: row[1]})
MERGE (t)-[:USES]->(p)
SET p.inUse = true,
t.inUse = true;

// LOAD CSV FROM $customerSystem + $prod + "ENTRYID_USERSPD.TXT" as row FIELDTERMINATOR '\t'
// MERGE (t:TRAN {label: row[0]})
// WITH toFloat(row[1]) as usersPD, t
// set t.usersPD = usersPD;
//
//

LOAD CSV FROM $customerSystem + $prod + "JOBS.TXT" as row FIELDTERMINATOR '\t'
MATCH (t:TRAN {label: "JOB"})
MERGE (p:PROG {label: row[0]})
MERGE (t)-[:USES]->(p);

And here is the error:

Neo.ClientError.Statement.SyntaxError: Invalid input '$': expected (line 1, column 1 (offset: 0))
"$customerSystem + $prod + "ENTRYID_USERSPD.TXT" as row FIELDTERMINATOR '\t'// WITH toFloat(row[1]) as usersPD, t//"
^

Most likely it is something stupid that I can't see! I have tried everything - and found that the only thing that works is removing the commented lines!

Thanks a lot for your help!!

5 REPLIES 5

intouch_vivek
Graph Steward

Hi @rmasrani,

Are sure you are running 3 scripts at a time as it is given in the above post?
Reason I asked because error is at line 1 column 1 and due to $ sign. Also error says there is no statement between ** "$customerSystem + $prod + "ENTRYID_USERSPD.TXT" as row FIELDTERMINATOR '\t'// WITH toFloat(row[1]) as usersPD, t//" ** however in your code I see a statement // MERGE (t:TRAN {label: row[0]})

Hi. There is a script between the first LOAD and the "t.inUse = true;", then there are 6 lines of comments, followed by another script. If I delete the comments everything is fine!

Here is another one:

Line 1: :param x => "value 1";
Line 2: // :param x => "value 2";

error:

Error: Syntax error at line 1 col 1:

:param customerSystem => "file:///C:/Users/rmasr/Code%20Excellence/S4HANA%20N4J%20-%20Documents/DATA/-----/";
^
Unexpected ":".

You cannot have multiple LOAD CSV in the same transaction.

For the parameters if you want to have multiple cypher statements executed in the same transactions (same edit window) then enable "Enable multi statement query editor" in the browser settings.

Thanks Anthony. I do have multi statement enabled, and in total I have about 200 cypher statements that get executed. I have been doing this for over a year now with no issues. The comment problem is relatively new and has been replicated by Vivek.

I have replied to Vivek's topic also.

I was able to execute the multiple statements without any error in the latest desktop browser as well as loading the url in browser.

See the screenshot below