Code query

Neo4j Desktop 1.1.13
Neo4j 3.5.1
Neo4j Browser 3.1.14
code used:
LOAD CSV WITH HEADERS FROM
'C:\Users\Zainab\Desktop\dataset_clean1.csv' AS row
CREATE (:dataset{disease:row.disease, symptom:row.symptom,weight: toInt(row.patientweight)})
error arised:
Neo.ClientError.Statement.SyntaxError: Invalid input 's': expected four hexadecimal digits specifying a unicode character (line 2, column 6 (offset: 32))
"'C:\Users\Zainab\Desktop\dataset_clean1.csv' AS row" ^

Hi,

Use double quotes around file path string:

LOAD CSV WITH HEADERS FROM
"C:\Users\Zainab\Desktop\dataset_clean1.csv" AS row

-Kamal

actual error it shows is with the word Users in the file path string.
Invalid input 's': expected four hexadecimal digits specifying a unicode character (line 2, column 6 (offset: 32))

Hi,

Sorry I didn't catch another point: Here is the correct one:
"file:C:/Users/Zainab/Desktop/dataset_clean1.csv"

Use file: and forward slash.

Try this.

It would be better create a 'import' folder (name all lower case) in
C:\Neo4jDesktop\neo4jDatabases\database-xxxx\installation-3.5.0 (modify the path according to your installation directory)
and copy your .csv file into 'import' folder. Then it will be much simpler to refer.

"file:/dataset_clean1.csv"

-Kamal

yup, noticed and corrected it.

i have one more doubt,i have 2 csv files, one file has to be predefined and using that predefined csv file, other csv file has to be used.
how can i do it

Two files : customers.csv (id, name) and orders.csv (customerid, orderid)

1:

//Load customers......
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/customers.csv" As line
WITH line

CREATE (c:Customer {id:toInteger(line.id), name:line.name}) ;

2:

//Load orders...............
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/orders.csv" As line
WITH line

//create order node......
CREATE (o:Order {customerid:toInteger(line.customerid), ordid:toInteger(line.orderid)})
WITH line, o

//MATCH Customer node with id = line.customerid..............
MATCH (c:Customer {id:toInteger(line.customerid)})

//Create relationship.......
MERGE (c)-[:ORDERS]->(o)

;

You can follow this logic in your imports.
Check this blog:
https://neo4j.com/graphgist/800a57b2-bbd1-40d3-9dee-a00c4ef624e6

-Kamal

can both files be implemented at a single stretch

Yes. Like this

//Load customers......
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/customers.csv" As line
WITH line

CREATE (c:Customer {id:toInteger(line.id), name:line.name}) ;

//Load orders...............
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/orders.csv" As line
WITH line

//create order node......
CREATE (o:Order {customerid:toInteger(line.customerid), ordid:toInteger(line.orderid)})
WITH line, o

//MATCH Customer node with id = line.customerid..............
MATCH (c:Customer {id:toInteger(line.customerid)})

//Create relationship.......
MERGE (c)-[:ORDERS]->(o)

;

Make sure that you end each Load CSV with semicolon (;) .

-Kamal