neo4j-admin import relative folders on windows

espen_solbu
Node Link

Hello,

Question: for admin import, how can i use a different import folder than the default import folder, on versions later than 4.2.x? Preferrably relative folders rather than absolute folders

Background:

For my project, i have been using a pipeline that produce admin-importable CSV files.

i also have scripts for linux (bash) and windows (bat) that will run admin import from the NEO4j bin folder, and import the data in the import folder.

All this is copied to the machine running neo4j, either from S3 bucket, or git pull.

I currently do this primarily on linux servers, but also on Neo4j Desktop on Windows.

For this conversation, assume it is to c:\checkout on the windows

We now have a structure where my importable data is in c:\checkout\import\nodes\..... and the import script sits in c:\checkout\scripts

I have an env variable for where the binaries are located %NEO4J_BIN_PATH%

I have then been running the import command from c:\checkout:

%NEO4J_BIN_PATH%\neo4j-admin.bat import --nodes="import/nodes/......."

This is where i run into some problems with 4.3.0 and later (on Windows only).

  • On 4.2.x (Windows and Linux), this will then import the csv's from c:\checkout\import\nodes
  • On 4.3.0 and later, on Windows, this will try to import from <RDMS>\import folder

(On Linux it seems to work fine with the relative paths, even on newer versions)

  • I understand i can solve my issue by copying files from c:\checkout\import to <RDMS>\import, but i would prefer to find a solution that does not require additional copying.
  • I believe I can also solve the issue by using absolute paths rather than relative paths in the --nodes= statement, however due to the amount of files and folders included, I do not think it would work prepending the full path

So back to the question:

  • Using Windows and newer versions of Neo4j, is it possible to use a different import path than the <RDMS>/import path? and are there ways to do this with relative paths, e.g. using environment variables or config settings?

 

Thanks and regards

 

 

2 REPLIES 2

Rcolinp
Ninja
Ninja

Hey there @espen_solbu, I think I can lend some help! 

If you are looking to import (using neo4j-admin import and/or LOAD CSV) there is a setting in your neo4j.conf you can comment out to allow imports from any directory in your filesystem (absolute path or relative path). 

Within your neo4j.conf (towards the very top of the configuration file) you'll find the following setting: 

# This setting constrains all `LOAD CSV` import files to be under the `import` directory. Remove or comment it out to
# allow files to be loaded from anywhere in the filesystem; this introduces possible security problems. See the
# `LOAD CSV` section of the manual for details.
#dbms.directories.import=import

All that is required for you to do to allow neo4j-admin import from any specified absolute or relative path within the neo4j-admin import command is to comment out "dbms.directories.import=import" as follows:

#dbms.directories.import=import

As stated in the the conf file, this is not recommended but doing this will enable you to import via desired relative/absolute path you'd like! Hope this helps! 

Best,
Rob

Thanks, 

Actually that was the first i tried... (However i was somewhat tentative as i saw it was set the same in my 4.2. instance that worked, as in my 4.4 instance that didn't work. Also since that hasn't been needed on my Linux or Mac instances.

I could not notice any difference with that setting commented out. I might have made a mistake though, I'll try the setting again just to confirm

Regards

Espen