Accessing to csv files in GDrive from Neo4j Aura
You can easily access to csv files saved in storage from a Neo4j Desktop installation, by issuing a command like the following:
LOAD CSV WITH HEADERS FROM "file:///path/to/the/actual/file.csv"
MERGE ...
but how do you manage to do this with a hosted Neo4j Aura instance?
Neo4j Aura mainly allows you to import files in two manners:
- by loading the csv / tsv files and a json file that defines the data model, using the Data Importer tool
- by loading the csv files on Google Drive, then using it directly to load the data in the instance
The first option gives us an easy way with a GUI to import the data, but requires us to have a data model prepared in json. If we would like to first load the csv file, then manually issue the MERGE commands afterwards, we can choose the second option.
- First of all, load the file to Google Drive.
- Then right click over the uploaded file and select “Get shareable link”.
- In the dialog box, under the “General access” section, click on “Restricted” and choose “Anyone with the link” from the dropdown menu.
- Click on “Copy link”, paste it in a textbox. You should get an address such as the following:
https://drive.google.com/file/d/gsbhokX66koMG7dMRtHQsuZrL6m7APbpT/view?usp=sharing
. Select and copy the file id, after the/d/
and before the/view
. - Replace the file id in the following link:
https://drive.google.com/uc?export=download&id=FILE_ID
. This will be the link of the file that you will be using in Neo4j Aura.
Now you can issue the command in the Neo4j Aura Console as you would do in the Desktop instance, just by replacing the filename with the address that you got earlier:
LOAD CSV WITH HEADERS FROM "https://drive.google.com/uc?export=download&id=FILE_ID"
MERGE ...
Et voilà!