我正在尝试使用neo4j-admin import将CSV输入数据填充到neo4j数据库中。根据文档,不支持使用\"转义引号,但我的输入存在这些和其他格式异常。因此,对于输入CSV,neo4j-admin import显然是失败的
> neo4j-admin import --mode=csv --id-type=INTEGER \
> --high-io=true \
> --ignore-missing-nodes=true \
> --ignore-duplicate-nodes=true \
> --nodes:user="import/headers_users.csv,import/users.csv"
Neo4j version: 3.5.11
Importing the contents of these files into /data/databases/graph.db:
Nodes:
:user
/var/lib/neo4j/import/headers_users.csv
/var/lib/neo4j/import/users.csv
Available resources:
Total machine memory: 15.58 GB
Free machine memory: 598.36 MB
Max heap memory : 17.78 GB
Processors: 8
Configured max memory: -2120992358.00 B
High-IO: true
IMPORT FAILED in 97ms.
Data statistics is not available.
Peak memory usage: 0.00 B
Error in input data
Caused by:ERROR in input
data source: BufferedCharSeeker[source:/var/lib/neo4j/import/users.csv, position:91935, line:866]
in field: company:string:3
for header: [user_id:ID(user), login:string, company:string, created_at:string, type:string, fake:string, deleted:string, long:string, lat:string, country_code:string, state:string, city:string, location:string]
raw field value: yyeshua
original error: At /var/lib/neo4j/import/users.csv @ position 91935 - there's a field starting with a quote and whereas it ends that quote there seems to be characters in that field after that ending quote. That isn't supported. This is what I read: 'Universidad Pedagógica Nacional \"F'我的问题是,是否有可能跳过或忽略neo4j-admin import抛出错误的CSV文件中格式不佳的行。在the docs中似乎没有这样的选项。我知道已经存在使用LOAD CSV的解决方案,并且CSV应该在导入之前进行预处理。注意:当我修复格式问题时,我能够成功导入CSV。
发布于 2019-10-23 18:01:30
也许有必要描述一下批量导入程序和加载CSV之间的区别。
LOAD CSV会将数据以事务方式加载到数据库中--这意味着你得到了所有ACID的好处,等等。这样做的副作用是它不是加载数据的最快方法。
批量导入程序假定数据是数据库可用的格式,您已经处理过重复项、将其转换为正确格式所需的任何处理,等等,并将按原样提取数据并将其格式化为指定的数据库。这不是数据的事务性加载,而且因为它假设加载的数据已经“数据库就绪”,所以它确实被非常快地摄取。
还有其他导入数据的选项,但通常情况下,如果您需要在导入时执行某种类型的行跳过/更正,您并不是真的希望通过离线批量导入程序来执行此操作。我建议您在使用,neo4j-admin import之前在CSV上进行某种形式的预处理,或者查看其他可用的导入选项之一,在这些选项中,您可以指定如何处理任何格式不佳的行。
https://stackoverflow.com/questions/58348418
复制相似问题