Matter with CSV Import

28 views
Skip to first unread message

Denis Schneider

unread,
Feb 23, 2015, 4:07:05 AM2/23/15
to ne...@googlegroups.com
Hi,

I have a problem with the csv import :

in my csv i have a string: "{3210,3211,3212}" which register id's of another nodes.
When i try to MERGE the relationship between a node (previously created by the import script) with some another nodes (whom already exist) like this :

...

WITH itm
, line
FOREACH
(rubId in split(replace(replace(replace(line.tag, "{", ""), "}", ""), " ", ""), ",") |
   MERGE
(itm)-[:BELONGS_TO]->(r:Rub { uid: toInt(rubId) }));


the script fail like this :

ERROR (-v for expanded information):
   
LoadCsvStatusWrapCypherException: Node 206 already exists with label Rub and property "uid"=[3210]



Somebody can help me ?

Andrii Stesin

unread,
Feb 27, 2015, 5:21:19 AM2/27/15
to ne...@googlegroups.com
Maybe this example will help: row[4] here contains a collection (which length varies between lines from 0 to some N) of primary keys (stored inside nodes in corresponding string properties) separated by ';' and builds relationships from the node which has primary key eq row[0] to every node from that collection

LOAD CSV FROM "file:///home/stesin/preprocessed.csv" AS row
WITH row
[0] AS key, SPLIT(row[4], ';') AS k0
UNWIND k0 AS k
WITH key
, k
MATCH
 
(o:P {primary_key: key}), (oo:P {primary_key: k})
MERGE
 
(o)<-[r:KNOWS]-(oo);


Reply all
Reply to author
Forward
0 new messages