I am trying to use LOAD CSV and am having some challenges ... I want to create different kinds of nodes based on the content of a particular column in my csv (TYPE)
Example:
ID,NAME,VALUE,LABEL,TYPE,KEY,GROUP,COLOR,SIZE,RECORDS,SCOPE
3,ERKRS_11CO,11CO,"Operating Concern 1122",ERKRS,ERKRS_11CO,EOI,#FF99CC,1,0,False
5,ERKRS_8500,8500,"IDES Australia and New Zealand",ERKRS,ERKRS_8500,EOI,#FF99CC,1,0,False
21,KKBER_1000,1000,"Credit control area Europe",KKBER,KKBER_1000,EOI,#336699,1,0,False
329,KOKRS_1111,1111,"1111 CONTROLLING AREA IN",KOKRS,KOKRS_1111,EOI,#CC99FF,1,0,False
330,KOKRS_1112,1112,"US COMPANY",KOKRS,KOKRS_1112,EOI,#CC99FF,1,0,False
I first tried:
// Build Nodes
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS
FROM 'file:///mynodesfile.csv' AS line
CREATE (line.NAME:line.TYPE :ee { name: line.LABEL , color: line.COLOR, records: TOINT(line.RECORDS), scope: line.SCOPE } ) ;
which did not work at all. Then I tried
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS
FROM 'file:///mynodesfile.csv' AS line
WITH line
CASE line.TYPE
WHEN 'ERKRS' THEN
CREATE (e:ERKRS { ID: TOINT(line.ID) } )
WHEN 'KKBER' THEN
CREATE (e:KKBER { ID: TOINT(line.ID) } )
WHEN 'KOKRS' THEN
CREATE (e:KOKRS { ID: TOINT(line.ID) } )
SET e.name = line.LABEL
e.color = line.COLOR
e.records = TOINT(line.RECORDS)
e.scope = line.SCOPE )
;
Also not working.... Then I wrote a python program to generate the cypher clauses. Because the actual file is much larger than the sample I gave, I tried to load it via the cypher shell with cat mynodes.cql | ./bin/cypher-shell.bat -u yourneo4juser -p yourpassword (I'm using Windows, so I used power shell ....)
mynodes.cql first 4 records ....
USING PERIODIC COMMIT 500
CREATE (ROOT_EC3_800:ROOT:eoi { name: "Enterprise", records: 0, scope: "False"} )
CREATE (ERKRS_11CO:ERKRS:eoi { name: "Operating Concorn 1122", records: 0, scope: "False"} )
CREATE (ERKRS_8500:ERKRS:eoi { name: "IDES Australia and New Zealand", records: 0, scope: "False"} )
Invalid input 'C': expected whitespace, comment or LoadCSVQuery (line 2, column 1 (offset: 26)) "CREATE (ROOT_EC3_800:ROOT:eoi { name: "Enterprise", records: 0, scope: "False"} )"
Yet, entering CREATE (ROOT_EC3_800:ROOT:eoi { name: "Enterprise", records: 0, scope: "False"} ) at the neo4j browser, the node is created.
I am trying very hard to make this work. Any help appreciated.