cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How do I split the data in the column while loading in neo4j using neo4j-admin import? parsing issue

Hello all,
I have a node and relationship csv. In relationship, I have a column where I need to split the column on a pipe. I tried using --array-delimiter = '|' but It doesn't split the data. My data looks like

node.csv

identifier:ID,name:LABEL
1,apple
2,ball
3,cat
rel.csv

source_ids:START_ID,target_ids:END_ID,type:TYPE,data
1,2,connection,
2,3,relation,test1|test2
3,1,connection,test1
1,3,relation,test4|test3|tet6

I used the code
neo4j-admin import --verbose --ignore-extra-columns=true --array-delimiter "|" --nodes C:/Users/Sam/Documents/node.csv --relationships C:/Users/Sam/Documents/rel.csv.

The result I get is :

{
 "data": "test4|test3|tet6"
}

what I want is :

{
  "data": ["test4","test3","tet6"]
}

I am using Neo4j 4.0.0 community.

2 REPLIES 2

clem
Graph Steward

I think you need to do something like:

  1. Change import directory
    dbms.directories.import=import
    to
    dbms.directories.import=ABSOLUTE_DIRECTORY_PATH

and run Cypher like this, using the split function String functions - Neo4j Cypher Manual

LOAD CSV WITH HEADERS FROM "file:///node.csv" AS row
CREATE (node:Label {data: split(row.data, '|')} )

You might have to do a second pass to create the relationships, which will require something like a MATCH for the node and then separate CREATE/MERGE for the relationship.

I hope that helps.

anthapu
Graph Fellow

Default data type is string for data. May be you can try changing this line to

source_ids:START_ID,target_ids:END_ID,type:TYPE,data:string[]

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online