2.13 毕业设计
作者:互联网
1.neo4j创建新的数据库
由于使用Neo3.x创建新数据库而不删除现有数据库,所以只需在$NEO4J_HOME
的conf
的目录编辑neo4j.conf
。
搜寻dbms.active_database=
,其默认值应为graph.db
。用其他名称替换它,然后再次启动neo4j。现在,将在该目录名下创建一个新数据库。若要切换回以前的db,请重复这些步骤,只需将新值替换为graph.db
在配置文件中。
2.pycharm永久激活
https://shimo.im/docs/ckprWXRyDcTydv6t/read
3.csv保存文件时默认位ansi编码,需要使用记事本打开保存问utf-8编码
4.label!!!!!!因为一个字母拼写错误浪费一下午时间
5.今日大头
neo4j 导入csv文件
参考知乎教程
admin-import 或 neo4j-import
- 适用场景:千万以上 nodes
- 速度:非常快 (xw/s)
- 优点:官方出品,占用更少的资源
- 缺点:需要转成CSV;必须停止neo4j;只能生成新的数据库,而不能在已存在的数据库中插入数据。
-
admin-import 基本语法
neo4j-admin import
[--mode=csv]
[--database=<name>]
[--additional-config=<config-file-path>]
[--report-file=<filename>]
[--nodes[:Label1:Label2]=<"file1,file2,...">]
[--relationships[:RELATIONSHIP_TYPE]=<"file1,file2,...">]
[--id-type=<STRING|INTEGER|ACTUAL>]
[--input-encoding=<character-set>]
[--ignore-extra-columns[=<true|false>]]
[--ignore-duplicate-nodes[=<true|false>]]
[--ignore-missing-nodes[=<true|false>]]
[--multiline-fields[=<true|false>]]
[--delimiter=<delimiter-character>]
[--array-delimiter=<array-delimiter-character>]
[--quote=<quotation-character>]
[--max-memory=<max-memory-that-importer-can-use>]
[--f=<File containing all arguments to this
import>]
[--high-io=<true/false>]
-
- --ignore-extra-columns=true 忽略多余列参数
- --ignore-missing-nodes=true 忽略失去节点参数
- --ignore-duplicate-nodes=true 忽略重复节点参数
导入数据示例:
示例一
三个csv
movies.csv
movie:ID,name,:LABEL
tt0133093,The
Matrix,movie
tt0234215,The
Matrix
Reloaded,movie
tt0242653,The
Matrix
Revolutions,movie
actors.csv
person:ID,name,:LABEL
keanu,Keanu
Reeves,person
laurence,Laurence
Fishburne,person
carrieanne,Carrie-Anne
Moss,person
roles.csv
:START_ID,role,:END_ID
keanu,Neo,tt0133093
keanu,Neo,tt0234215
keanu,Neo,tt0242653
laurence,Morpheus,tt0133093
laurence,Morpheus,tt0234215
laurence,Morpheus,tt0242653
carrieanne,Trinity,tt0133093
需要一次性全部导入
neo4j-import 导入
.\bin\neo4j-import
--into data\databases\graph.db --nodes .\import\practice\actors.csv --nodes .\import\practice\movies.csv --relationships:ACTED_IN .\import\practice\roles.csv --skip-duplicate-nodes=true
--skip-bad-relationships=true
--stacktrace --bad-tolerance=500000
neo4j-admin 导入
.\bin\neo4j-admin import
--database=graph.db --nodes .\import\practice\actors.csv --nodes .\import\practice\movies.csv --relationships:ACTED_IN .\import\practice\roles.csv
movies3-header.csv
movieId:ID,title,year:int,:LABEL
movies3.csv
tt0133093,"The Matrix",1999,Movie
tt0234215,"The Matrix Reloaded",2003,Movie;Sequel
tt0242653,"The Matrix Revolutions",2003,Movie;Sequel
actors3-header.csv
personId:ID,name,:LABEL
actors3.csv
keanu,"Keanu Reeves",Actor
laurence,"Laurence Fishburne",Actor
carrieanne,"Carrie-Anne Moss",Actor
roles3-header.csv
:START_ID,role,:END_ID,:TYPE
roles3.csv
keanu,"Neo",tt0133093,ACTED_IN
keanu,"Neo",tt0234215,ACTED_IN
keanu,"Neo",tt0242653,ACTED_IN
laurence,"Morpheus",tt0133093,ACTED_IN
laurence,"Morpheus",tt0234215,ACTED_IN
laurence,"Morpheus",tt0242653,ACTED_IN
carrieanne,"Trinity",tt0133093,ACTED_IN
carrieanne,"Trinity",tt0234215,ACTED_IN
carrieanne,"Trinity",tt0242653,ACTED_IN
导入脚本
neo4j_home$ bin/neo4j-admin import
--nodes="import/movies3-header.csv,import/movies3.csv"
--nodes="import/actors3-header.csv,import/actors3.csv"
--relationships="import/roles3-header.csv,import/roles3.csv"
示例三
neo4j-admin import
--mode=csv --database=userMovie.db --nodes data_test\movies.csv --nodes data_test\actors.csv --relationships data_test\roles.csv
bin/neo4j-admin import
--nodes:Movie
import/movie_node.csv --relationships:ACTED_IN=import/roles5b.csv
中途导入时可以用上述方法 - .\bin\neo4j-import --into data\databases\test.db --nodes .\import\node\person.csv --nodes .\import\node\movie.csv --relationships:ACTED_IN .\import\relation\actor.csv --nodes .\import\node\movie.csv --nodes .\import\node\country.csv --relationships:DISTRICT_IN .\import\relation\district.csv --nodes .\import\node\movie.csv --nodes .\import\node\person.csv --relationships:DIRECTOR_IN .\import\relation\director.csv --nodes .\import\node\movie.csv --nodes .\import\node\person.csv --relationships:COMPOSER_IN .\import\relation\composer.csv --skip-duplicate-nodes=true --skip-bad-relationships=true --stacktrace --bad-tolerance=500000
标签:--,ACTED,毕业设计,neo4j,import,nodes,csv,2.13 来源: https://www.cnblogs.com/gyf8/p/14401971.html