Home » Java » Load csv file in neo4j embedded in Java

Load csv file in neo4j embedded in Java

Posted by: admin October 23, 2018 Leave a comment


I have a neo4j embedded DB in my application and I want to load a .csv file to fill the database. I’ve managed to create the .csv file in the /import folder but when I try to load it, I get a Couldn't load the external resource at: file:/csv_file.csv.
I’ve read it may be something about permissions but I cannot change them since it creates the whole folder structure every time I run my application (I try to change them after creating the file with Runtime.getRuntime().exec("chmod 777 /path_to_file/csv_file.csv") but it never works)

This is my code:

public void addCSVtoDB() {
    try ( Transaction ignored = graphDb.beginTx();
            Result result = graphDb.execute( "LOAD CSV WITH HEADERS FROM \"file:///csv_file.csv\" AS csvLine\n" )


I’m using MacOSX 10.11 so the / are supposed to be allright. Any idea?