简体   繁体   English

关于将csv导入neo4j的问题

[英]Questions regarding importing csv into neo4j

I have three questions regarding importing csv: 关于导入csv,我有三个问题:

  1. Is it possible to make the command to ignore the first line in the csv files? 是否可以使命令忽略csv文件中的第一行? (As there are many files to import, it is inconvenient to change all of them) (由于要导入的文件很多,因此不方便更改所有文件)
  2. Is it possible to make the property of a relationship or node to be null if the corresponding property in csv files is empty? 如果csv文件中的对应属性为空,是否可以使关系或节点的属性为null?
  3. Is it possible to have the same type of nodes with different (number of) properties? 是否可能具有具有不同(数量)属性的相同类型的节点?

1) Yes you can use SKIP as well in LOAD CSV : 1)是的,您也可以在LOAD CSV中使用SKIP:

LOAD CSV WITH HEADERS FROM "file:///dummyfile.csv" AS row
WITH row
SKIP 1
MERGE (n:Node {id: row[0]})

2) If the csv column value is NULL, then the corresponding property value will be null as well. 2)如果csv列值为NULL,则相应的属性值也将为null。 If it is empty, then the property will not be created 如果为空,则不会创建该属性

Assume the following CSV : 假设以下CSV:

id,title,desc
1,title 1,desc1
2,,desc 2

And the following LOAD CSV : 以及以下LOAD CSV:

LOAD CSV WITH HEADERS FROM "https://gist.githubusercontent.com/ikwattro/ed85bfc98c9298924c154ecf3e0ab2aa/raw/54a9303c365a7698c87728d458f8de703a9c22e1/load.csv" AS row
CREATE (n:Post {id: row['id'], title: row['title'], description: row['desc']})

This would create the following : 这将创建以下内容:

╒══════════════════════════════════════════════════╕
│"n"                                               │
╞══════════════════════════════════════════════════╡
│{"description":"desc1","id":"1","title":"title 1"}│
├──────────────────────────────────────────────────┤
│{"description":"desc 2","id":"2"}                 │
└──────────────────────────────────────────────────┘

3) Yes, Neo4j being schemaless you don't need to have the same number of properties on nodes with the same label 3)是的,Neo4j是无模式的,在具有相同标签的节点上不需要具有相同数量的属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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