将csv导入neo4j缺失节点

时间:2017-12-03 09:13:37

标签: csv graph neo4j

我想将以下CSV文件导入neo4j

:START_ID,:END_ID,:TYPE
1, 2, call
2, 3, text
3, 2, text
6, 3, text
5, 6, text
5, 4, call
4, 1, call
4, 5, text
1, 5, call
1, 8, call
6, 8, call
6, 8, text
8, 6, text
7, 1, text

person:ID,name,value:int
1,Alice,1
2,Bob,0
3,Charlie,0
4,David,0
5,Esther,0
6,Fanny,0
7,Gabby,0
8,XXX,1

通过

导入
DATA_DIR_SAMPLE=/data_network/
$NEO4J_HOME/bin/neo4j-admin import --into ${NEO4J_HOME}/data/databases/social.db \
  --nodes:Person ${DATA_DIR_SAMPLE}/v.csv \
  --relationships ${DATA_DIR_SAMPLE}/e.csv \
  --ignore-empty-strings true \
  --skip-duplicate-nodes true \
  --skip-bad-relationships true \
  --bad-tolerance  1500 \
  --multiline-fields=true

告诉我,所有关系都包含缺少的节点。这有什么不对?

InputRelationship:
   source: /data_network/e.csv:2
   startNode: 1 (global id space)
   endNode:  2 (global id space)
   type:  call
 referring to missing node  2
InputRelationship:
   source: /data_network/e.csv:3
   startNode: 2 (global id space)
   endNode:  3 (global id space)
   type:  text
 referring to missing node  3
InputRelationship:
   source: /data_network/e.csv:4
   startNode: 3 (global id space)
   endNode:  2 (global id space)
   type:  text
 referring to missing node  2
InputRelationship:
   source: /data_network/e.csv:5
   startNode: 6 (global id space)
   endNode:  3 (global id space)
   type:  text
 referring to missing node  3
InputRelationship:
   source: /data_network/e.csv:6
   startNode: 5 (global id space)
   endNode:  6 (global id space)
   type:  text
 referring to missing node  6
InputRelationship:
   source: /data_network/e.csv:7
   startNode: 5 (global id space)
   endNode:  4 (global id space)
   type:  call
 referring to missing node  4
InputRelationship:
   source: /data_network/e.csv:8
   startNode: 4 (global id space)
   endNode:  1 (global id space)
   type:  call
 referring to missing node  1
InputRelationship:
   source: /data_network/e.csv:9
   startNode: 4 (global id space)
   endNode:  5 (global id space)
   type:  text
 referring to missing node  5
InputRelationship:
   source: /data_network/e.csv:10
   startNode: 1 (global id space)
   endNode:  5 (global id space)
   type:  call
 referring to missing node  5
InputRelationship:
   source: /data_network/e.csv:11
   startNode: 1 (global id space)
   endNode:  8 (global id space)
   type:  call
 referring to missing node  8
InputRelationship:
   source: /data_network/e.csv:12
   startNode: 6 (global id space)
   endNode:  8 (global id space)
   type:  call
 referring to missing node  8
InputRelationship:
   source: /data_network/e.csv:13
   startNode: 6 (global id space)
   endNode:  8 (global id space)
   type:  text
 referring to missing node  8
InputRelationship:
   source: /data_network/e.csv:14
   startNode: 8 (global id space)
   endNode:  6 (global id space)
   type:  text
 referring to missing node  6
InputRelationship:
   source: /data_network/e.csv:15
   startNode: 7 (global id space)
   endNode:  1 (global id space)
   type:  text
 referring to missing node  1

2 个答案:

答案 0 :(得分:1)

添加额外的     :标签 专栏正在解决这个问题。

答案 1 :(得分:0)

您需要在节点csv文件中添加:LABEL列,以告诉neo4j您为节点创建了什么标签。它应该看起来像这样:

person:ID,name,value:int,:LABEL
1,Alice,1,person
2,Bob,0,person
3,Charlie,0,person
.
.
.

然后需要提到的是,您正在使用关系文件中的标签person连接节点。

:START_ID(person),:END_ID(person),:TYPE
1, 2, call
2, 3, text
3, 2, text
.
.
.

注意:您可以给其他标签代替person