问题
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