简体   繁体   中英

Get node label name from csv file

I am importing csv file from import directory by cypher and I would like to create nodes with labels from csv file. Which would look something like this

LOAD CSV WITH HEADERS FROM "file:///B.csv" AS csv
CREATE (c:csv.Type {name:csv.Name})
return c 

I know that this is wrong, but hope you can show me the right way to do it. I couldn't find any answer in both neo4j community and in stackoverflow.

from neo4j community dana.canzano 's answer. It could be implemented by apoc library. Here is the code.

load csv with headers from 'file:///B.csv' as row 
call apoc.create.node([row.label],{name: row.name}) 
yield node return count(node);

You can find more details in community page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM