2.13 毕业设计

1.neo4j创建新的数据库

由于使用Neo3.x创建新数据库而不删除现有数据库,所以只需在$NEO4J_HOMEconf的目录编辑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 基本语法

    1. neo4j-admin import [--mode=csv] [--database=<name>]
    2. [--additional-config=<config-file-path>]
    3. [--report-file=<filename>]
    4. [--nodes[:Label1:Label2]=<"file1,file2,...">]
    5. [--relationships[:RELATIONSHIP_TYPE]=<"file1,file2,...">]
    6. [--id-type=<STRING|INTEGER|ACTUAL>]
    7. [--input-encoding=<character-set>]
    8. [--ignore-extra-columns[=<true|false>]]
    9. [--ignore-duplicate-nodes[=<true|false>]]
    10. [--ignore-missing-nodes[=<true|false>]]
    11. [--multiline-fields[=<true|false>]]
    12. [--delimiter=<delimiter-character>]
    13. [--array-delimiter=<array-delimiter-character>]
    14. [--quote=<quotation-character>]
    15. [--max-memory=<max-memory-that-importer-can-use>]
    16. [--f=<File containing all arguments to this import>]
    17. [--high-io=<true/false>]
      • --ignore-extra-columns=true 忽略多余列参数
      • --ignore-missing-nodes=true 忽略失去节点参数
      • --ignore-duplicate-nodes=true 忽略重复节点参数

      导入数据示例:

      示例一

      三个csv

      movies.csv

      1. movie:ID,name,:LABEL
      2. tt0133093,The Matrix,movie
      3. tt0234215,The Matrix Reloaded,movie
      4. tt0242653,The Matrix Revolutions,movie

       

      actors.csv

      1. person:ID,name,:LABEL
      2. keanu,Keanu Reeves,person
      3. laurence,Laurence Fishburne,person
      4. carrieanne,Carrie-Anne Moss,person

       

      roles.csv

      1. :START_ID,role,:END_ID
      2. keanu,Neo,tt0133093
      3. keanu,Neo,tt0234215
      4. keanu,Neo,tt0242653
      5. laurence,Morpheus,tt0133093
      6. laurence,Morpheus,tt0234215
      7. laurence,Morpheus,tt0242653
      8. carrieanne,Trinity,tt0133093

       需要一次性全部导入

      neo4j-import 导入

      1. .\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 导入

      1. .\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

    1. movieId:ID,title,year:int,:LABEL

     

    movies3.csv

    1. tt0133093,"The Matrix",1999,Movie
    2. tt0234215,"The Matrix Reloaded",2003,Movie;Sequel
    3. tt0242653,"The Matrix Revolutions",2003,Movie;Sequel

     

    actors3-header.csv

    1. personId:ID,name,:LABEL

     

    actors3.csv

    1. keanu,"Keanu Reeves",Actor
    2. laurence,"Laurence Fishburne",Actor
    3. carrieanne,"Carrie-Anne Moss",Actor

     

    roles3-header.csv

    1. :START_ID,role,:END_ID,:TYPE

     

    roles3.csv

    1. keanu,"Neo",tt0133093,ACTED_IN
    2. keanu,"Neo",tt0234215,ACTED_IN
    3. keanu,"Neo",tt0242653,ACTED_IN
    4. laurence,"Morpheus",tt0133093,ACTED_IN
    5. laurence,"Morpheus",tt0234215,ACTED_IN
    6. laurence,"Morpheus",tt0242653,ACTED_IN
    7. carrieanne,"Trinity",tt0133093,ACTED_IN
    8. carrieanne,"Trinity",tt0234215,ACTED_IN
    9. carrieanne,"Trinity",tt0242653,ACTED_IN

     

    导入脚本

    1. 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"

     

    示例三

    1. neo4j-admin import --mode=csv --database=userMovie.db --nodes data_test\movies.csv --nodes data_test\actors.csv --relationships data_test\roles.csv
    2. 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
posted @ 2021-02-14 14:52  FF_FF1  阅读(42)  评论(0编辑  收藏  举报