从neo4j中的大型csv文件仅加载少量样本 [英] Load only few samples from large csv file in neo4j
问题描述
我是neo4j db的新手.我的csv文件很大,无法放入机器的ram中.在使用USING PERIODIC COMMIT
将所有记录加载到db中之前,我想在少量数据样本上测试cypher查询.如何加载仅加载1000行数据并测试我的查询.
I am new for neo4j db. I've a large csv file which cannot fit in my machine's ram. Before I load all the records in db using USING PERIODIC COMMIT
, I want to test my cypher query on the small sample of data. How can I load load just 1000 rows of data and test out my query.
数据的简化列为[Employee, CompanyName]
.我想将关系创建为(:Employee)-[:Employed]->(:Company)
. Employee和CompanyName节点已被加载到数据库中.
The data has columns in simplified form as [Employee, CompanyName]
. I want to create relationship as (:Employee)-[:Employed]->(:Company)
. The Employee and the CompanyName nodes are already loaded into the database.
推荐答案
您可以限制要导入的行:
You can limit the rows you want to import with:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS 'file:///yourcsvfile.csv' AS row
WITH row LIMIT 1000
...
,然后继续执行通常的导入Cypher语句.这只会读取文件的前1000行.
and then continue with your usual import Cypher statements. This will read only the first 1000 lines of your file.
这篇关于从neo4j中的大型csv文件仅加载少量样本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!