Try this:
LOAD CSV WITH HEADERS FROM 'file:///test.txt' AS row FIELDTERMINATOR '|'
WITH row LIMIT 10
MERGE (c:client {client_no: toInteger(row.customer_no)})
MERGE (p:product {product_number: toInteger(row.product_no)})
//in .csv all the values will be in string format... use this to covert to date format
WITH apoc.date.format(apoc.date.parse(row.purchase_date, 'ms', 'yyyy-MM-dd'), 'ms', 'yyyy-MM-dd') as purchdte, c, p
MERGE(c)-[:BOUGHT {purchase_date: purchdte}]->(p)
I'd like to add this information to existing nodes 'client' so I have
page <-[VISITED]-client-[BOUGHT]->product
I start with:
(I want to create new node v and then find right node 'c' to finally build relationship)
LOAD CSV WITH HEADERS FROM 'file:///visits.txt' AS row FIELDTERMINATOR '|'
MERGE (v:Page {page_no: toInteger(row.visited_page)})
WITH MATCH
(c:Client), (v:Page)
WHERE c.client_no = toInteger(row.client_no) AND v.page_no = toInteger(row.visited_page)
MERGE (c)-[r:VISITED]->(v)
But I got "Variable c not defined"
EDIT
I composed such query (and looks like it works) - correct?
LOAD CSV WITH HEADERS FROM 'file:///visits.txt' AS row FIELDTERMINATOR '|'
MATCH
(c:Client {client_no: toInteger(row.client_no)})
MERGE (v:Page {page_no: toInteger(row.visited_page)})
CREATE (c)-[r:VISITED]->(v)
You cannot use 'WITH' before 'MATCH'. First use 'MATCH' to find a node and if you want propagate the node variable then you should WITH a (a is the node variable like MATCH(a:Customer)).
MATCH
(c:Client {client_no: toInteger(row.client_no)})
MERGE (v:Page {page_no: toInteger(row.visited_page)})
CREATE (c)-[r:VISITED]->(v)
Here you have to use 'WITH'
MATCH
(c:Client {client_no: toInteger(row.client_no)})
with c, row
MERGE (v:Page {page_no: toInteger(row.visited_page)})
CREATE (c)-[r:VISITED]->(v)