Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load only few samples from large csv file in neo4j

Tags:

csv

neo4j

cypher

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.

like image 513
smm Avatar asked Jan 29 '23 18:01

smm


1 Answers

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.

like image 151
Fabio Lamanna Avatar answered Feb 08 '23 13:02

Fabio Lamanna