# Code query

**URL:** <https://community.neo4j.com/t/code-query/4552>\
**Category:** Cypher\
**Created:** [January 23, 2019, 3:06am UTC](https://community.neo4j.com/t/code-query/4552 "2019-01-23T03:06:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zainabjabeen26](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zainabjabeen26/32/2975_2.png) [@zainabjabeen26](https://community.neo4j.com/u/zainabjabeen26)\
**Post date:** [January 23, 2019, 3:06am UTC](https://community.neo4j.com/t/code-query/4552/1 "2019-01-23T03:06:03Z")

</div>

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" ^

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [January 23, 2019, 3:55am UTC](https://community.neo4j.com/t/code-query/4552/2 "2019-01-23T03:55:22Z")

</div>

Hi,

Use double quotes around file path string:

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

-Kamal

---

<div class="post-metadata">

**Author:** ![zainabjabeen26](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zainabjabeen26/32/2975_2.png) [@zainabjabeen26](https://community.neo4j.com/u/zainabjabeen26)\
**Post date:** [January 23, 2019, 4:06am UTC](https://community.neo4j.com/t/code-query/4552/3 "2019-01-23T04:06:58Z")

</div>

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))

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [January 23, 2019, 4:30am UTC](https://community.neo4j.com/t/code-query/4552/4 "2019-01-23T04:30:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zainabjabeen26](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zainabjabeen26/32/2975_2.png) [@zainabjabeen26](https://community.neo4j.com/u/zainabjabeen26)\
**Post date:** [January 23, 2019, 5:07am UTC](https://community.neo4j.com/t/code-query/4552/5 "2019-01-23T05:07:49Z")

</div>

yup, noticed and corrected it.

---

<div class="post-metadata">

**Author:** ![zainabjabeen26](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zainabjabeen26/32/2975_2.png) [@zainabjabeen26](https://community.neo4j.com/u/zainabjabeen26)\
**Post date:** [January 23, 2019, 5:09am UTC](https://community.neo4j.com/t/code-query/4552/6 "2019-01-23T05:09:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [January 23, 2019, 5:47am UTC](https://community.neo4j.com/t/code-query/4552/7 "2019-01-23T05:47:37Z")

</div>

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](https://neo4j.com/graphgist/800a57b2-bbd1-40d3-9dee-a00c4ef624e6)

-Kamal

---

<div class="post-metadata">

**Author:** ![zainabjabeen26](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zainabjabeen26/32/2975_2.png) [@zainabjabeen26](https://community.neo4j.com/u/zainabjabeen26)\
**Post date:** [January 23, 2019, 6:37am UTC](https://community.neo4j.com/t/code-query/4552/8 "2019-01-23T06:37:23Z")

</div>

can both files be implemented at a single stretch

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [January 23, 2019, 7:34am UTC](https://community.neo4j.com/t/code-query/4552/9 "2019-01-23T07:34:30Z")

</div>

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
