Neo4j导入csv数据错误for header: [classId:ID, name:string, :LABEL]

今天在用Neo4j的时候出现了下面的错误:

➜  installation-3.5.6 ./bin/neo4j-admin import --mode=csv --database=graph.db --nodes /Users/admin/Documents/data/knowledgeGraph/students.csv,/Users/admin/Documents/data/knowledgeGraph/classes.csv --relationships /Users/admin/Documents/data/knowledgeGraph/relations.csv
Neo4j version: 3.5.6
Importing the contents of these files into /Users/admin/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-42c2a528-01e9-4145-99ad-da0123d20d59/installation-3.5.6/data/databases/graph.db:
Nodes:
  /Users/admin/Documents/data/knowledgeGraph/students.csv
  /Users/admin/Documents/data/knowledgeGraph/classes.csv
Relationships:
  /Users/admin/Documents/data/knowledgeGraph/relations.csv

Available resources:
  Total machine memory: 16.00 GB
  Free machine memory: 194.43 MB
  Max heap memory : 910.50 MB
  Processors: 8
  Configured max memory: 13.60 GB
  High-IO: true

WARNING: 122.18 MB memory may not be sufficient to complete this import. Suggested memory distribution is:
heap size: 1.00 GB
minimum free and available memory excluding heap size: 1020.01 MBImport starting 2019-07-30 19:15:47.680+0800
  Estimated number of nodes: 11.00 
  Estimated number of node properties: 22.00 
  Estimated number of relationships: 6.00 
  Estimated number of relationship properties: 0.00 
  Estimated disk space usage: 831.00 B
  Estimated required memory usage: 1020.01 MB

InteractiveReporterInteractions command list (end with ENTER):
  c: Print more detailed information about current stage
  i: Print more detailed information

(1/4) Node import 2019-07-30 19:15:47.715+0800
  Estimated number of nodes: 11.00 
  Estimated disk space usage: 627.00 B
  Estimated required memory usage: 1020.01 MB
.......... .......... .......... .......... ..........   5% ∆61ms
.......... .......... .......... .......... ..........  10% ∆2ms
.......... .......... .......... .......... ..........  15% ∆0ms
.......... .......... .......... .......... ..........  20% ∆1ms
.......... .......... .......... .......... ..........  25% ∆0ms
.......... .......... .......... .......... ..........  30% ∆1ms
.......... .......... .......... .......... ..........  35% ∆0ms
.......... .......... .......... .......... ..........  40% ∆1ms
.......... .......... .......... .......... ..........  45% ∆0ms
.......... .......... .......... .......... ..........  50% ∆1ms
.......... .......... .......... .......... ..........  55% ∆1ms
.......... .......... .......... .......... ..........  60% ∆0ms
.......... .......... .......... .......... ..........  65% ∆1ms
.......... .......... .......... .......... ..........  70% ∆1ms
.......... .......... .......... .......... ..........  75% ∆0ms
.......... .......... .......... .......... ..........  80% ∆1ms
.......... .......... .......... .......... ..........  85% ∆0ms
.......... .......... .......... .......... ..........  90% ∆1ms
.......... .......... .......... .......... ..........  95% ∆0ms
.......... .......... .......... .......... .......... 100% ∆0ms


IMPORT FAILED in 262ms. 
Data statistics is not available.
Peak memory usage: 0.00 B
Error in input data
Caused by:ERROR in input
  data source: BufferedCharSeeker[source:/Users/admin/Documents/data/knowledgeGraph/classes.csv, position:34, line:1]
  in field: :LABEL:4
  for header: [classId:ID, name:string, :LABEL]
  raw field value: :LABEL
  original error: Extra column not present in header on line 1 in /Users/admin/Documents/data/knowledgeGraph/classes.csv with value :LABEL

WARNING Import failed. The store files in /Users/admin/Library/Application Support/Neo4j Desktop/Application/neo4jDatabases/database-42c2a528-01e9-4145-99ad-da0123d20d59/installation-3.5.6/data/databases/graph.db are left as they are, although they are likely in an unusable state. Starting a database on these store files will likely fail or observe inconsistent records so start at your own risk or delete the store manually
unexpected error: ERROR in input
  data source: BufferedCharSeeker[source:/Users/admin/Documents/data/knowledgeGraph/classes.csv, position:34, line:1]
  in field: :LABEL:4
  for header: [classId:ID, name:string, :LABEL]
  raw field value: :LABEL
  original error: Extra column not present in header on line 1 in /Users/admin/Documents/data/knowledgeGraph/classes.csv with value :LABEL

我的文件为class.csv:

studentId:ID,name,age:int,:LABEL
s1,"JM68",27,Student
s2,"JM6",22,Student
s3,"JM8",18,Student
s4,"JM",2,Student

students.csv:

classId:ID,name,:LABEL
c1,"MHT班",Class
c2,"MY班",Class
c3,"LYH班",Class
c4,"RZF班",Class

relations.csv:

:START_ID,:END_ID,:TYPE
s1,c4,FROM
s2,c2,FROM
s3,c3,FROM
s4,c1,FROM

然后我运行的命令为:

./bin/neo4j-admin import --mode=csv --database=graph.db --nodes 
/Users/admin/Documents/data/knowledgeGraph/students.csv,
/Users/admin/Documents/data/knowledgeGraph/classes.csv 
--relationships /Users/admin/Documents/data/knowledgeGraph/relations.csv

解决方法

 

./bin/neo4j-admin import --mode=csv --database=graph.db 
--nodes /Users/admin/Documents/data/knowledgeGraph/students.csv 
--nodes /Users/admin/Documents/data/knowledgeGraph/classes.csv 
--relationships /Users/admin/Documents/data/knowledgeGraph/relations.csv

原因是我只写了一个 nodes参数,然后读取了两个文件,neo4j以为格式都是一样的。最后分开读nodes文件就行了。

参考文献

[1]. 使用 官方 etl neo4j-import 导入 数据. http://weikeqin.com/2017/04/11/neo4j-import/

[2]. Neo4j--数据导入. https://www.jianshu.com/p/e968c5ccf34c

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值