Load only few samples from large csv file in neo4j

我是研究僧i 提交于 2020-01-04 05:36:39

问题


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.

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.


回答1:


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

and then continue with your usual import Cypher statements. This will read only the first 1000 lines of your file.




回答2:


Just create a csv file with the first 1000 lines of your file (and then work with that). On Linux/Unix :

head -1000 yourinputfile.csv > output1000.csv

On Windows (powershell) :

Get-Content "yourinputfile.csv" | select -First 1000 | Out-File "output1000.csv"

Hope this helps.

Regards, Tom



来源:https://stackoverflow.com/questions/45809240/load-only-few-samples-from-large-csv-file-in-neo4j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!