赞
踩
特别说明:注意 csv里边的headline要是英文,
开始时候最好删除所有,我是删除了 D://NoSQL//Neo4J//neo4j_community_3.4.12//data//databases//graph.db再重新导入的
neo4J地址 http://localhost:7474/browser/
0.将这几个csv文件 人员表.csv;;物品表.csv;;关系表.csv 放到import目录下
- 人员表.csv
- card_id,year,salary
- 1,5,8554
- 2,5,9576
- 3,8,18752
- 4,4,7624
-
-
- 物品表.csv
- product_id,product_category,rate
- 1,1,0.005
- 2,1,0.002
- 3,1,0.004
-
-
- 关系表.csv
- card_id,product_id,sales_amount
- 1,1,18
- 1,2,59
- 1,3,29
- 2,3,99
- 2,2,39
- 3,1,40
- 4,2,54
1.首先尝试第一个,一次性导入(windows的cmd下操作):
cd到import文件夹下
neo4j-import --into D://NoSQL//Neo4J//neo4j_community_3.4.12//data//databases//graph.db --nodes 人员表.csv --nodes 物品表.csv --relationships:关系表.csv --skip-duplicate-nodes=true --skip-bad-relationships=true --stacktrace --bad-tolerance=500000
2.如果不行,再试试第二个(http://localhost:7474/browser/上操作):
- //一个一个csv文件依次输入,否则可能会报错
- //csv导入人员表
- USING PERIODIC COMMIT
- LOAD CSV WITH HEADERS FROM "file:///人员表.csv" AS row
- CREATE (S:Staff {card_id:row.card_id, year:row.year, salary:row.salary});
-
- //csv导入物品表.csv
- USING PERIODIC COMMIT
- LOAD CSV WITH HEADERS FROM "file:///物品表.csv" AS row
- CREATE (P:Product {product_id:row.product_id, product_category:row.product_category,
- rate:row.rate});
-
- //csv导入关系表
- LOAD CSV WITH HEADERS FROM "file:///关系表.csv" AS row
- match (S:Staff{card_id:row.card_id}), (P:Product{product_id:row.product_id})
- merge (S)-[r:rel{sales_amount:row.sales_amount}]->(P)
最后得到的结果是:
希望对你有所帮助
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。