Search code examples
.netneo4jneo4jclientgraphenedb

Can't load CSV data into GrapheneDB Instance


I'm using GrapheneDB to host my Neo4j instance, and am using Readify's Neo4jClient nuget library to connect to it from my locally-running MVC application, like so:

var uri = new Uri(HttpContext.Current.Server.MapPath("~/App_Data/Data.csv"));

client.Connect();

client.Cypher
    .LoadCsv(uri, "user")
    .Create("(u:User { Id: user[1], Name: user[2] })")
    .ExecuteWithoutResults();

This is throwing a LoadExternalResourceException:

Cannot load from URL 'file:///C:/source/blah/src/App_Data/Data.csv': configuration property 'dbms.security.allow_csv_import_from_file_urls' is false

Where and how am I to configure this parameter?

Secondly, is it necessary for the csv import file to be accessible from the Graphene DB instance, or is this a client concern?


Solution

  • The LOAD CSV clause is executed on the remote Neo4j instance, which has no access to the local filesystem.

    In order to load data from a CSV file on the remote instance, there would be two options:

    The file would need to be uploaded to the remote server's filesystem and the config setting dbms.security.allow_csv_import_from_file_urls should be set to true.

    This is not possible on GrapheneDB for obvious security reasons.

    Example:

    LOAD CSV FROM file://...

    Solution:

    The file is uploaded to a server or cloud service, i.e. AWS S3, Google Docs, Dropbox or your own server. LOAD CSV is used with the URL of the file. The file should be publicly accessible so that Neo4j can actually download the file to process it.

    Example:

    LOAD CSV FROM http://...

    This would