Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load CSV file from Dropbox for Neo4j

I saved my CSV file on dropbox and I want to Load them on Neo4j.

The link for the shared Users Node csv file: https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0

This is the cypher

USING PERIODIC COMMIT 100
        
LOAD CSV WITH HEADERS FROM "https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0" AS line
        
CREATE(u:User{userId: toInt(line.Id), username: line.UserName, fullname: line.FullName})

The Neo4j version I am using is Neo4j Enterprise version 3.0.9.

The result showed that it successfully created the Users Node but it created over 300 Nodes with no user name and full name. Even though there are 9 nodes with a user name and full name on the CSV file. What am I missing?

I tried to change the URL from the shared link to the download link but the error Couldn't load the external resource showed up.

like image 548
ash Avatar asked Jul 24 '17 14:07

ash


People also ask

How do I import a CSV file into Neo4j browser?

To import data from a CSV file into Neo4j, you can use LOAD CSV to get the data into your query. Then you write it to your database using the normal updating clauses of Cypher. A new node with the Artist label is created for each row in the CSV file.

How do I save a CSV file to Dropbox?

As soon as you are logged in, you'll have to upload your prepared CSV files into your Dropbox profile. To do so, click on the Upload files button and choose the needed files from your computer. You can also try loading and setting up the migration with our sample CSV files so that you know how the process goes on.

How do you define as field terminator in load csv?

When using LOAD CSV one can define the field delimiter used, whereby the default is the ',' character. LOAD CSV WITH HEADERS from 'file:///actors.csv' as row FIELDTERMINATOR '\u0080' RETURN row.name; the usage of '\u' as a FIELDTERMINATOR needs to be a 4 character zero padded value.

Where is the Neo4j import folder?

From the Open dropdown menu of your Neo4j instance, select Terminal, and navigate to <installation-version>/import.


2 Answers

If you switch from dropbox to gDrive the issue seems to not be an issue. I dropped your csv in my drive account and it seems to work.

USING PERIODIC COMMIT 100
LOAD CSV WITH HEADERS FROM "https://docs.google.com/spreadsheets/d/e/2PACX-1vRANVgt-GZf0Un8dyrf7YPITDgAIBzTwjTcqOu_G7mBhGKOEZskf6Mt2oTdInyQ-wLPE0aOzsW6lVD_/pub?gid=5399540&single=true&output=csv" AS line
CREATE(u:User{userId: toInt(line.Id), username: line.UserName, fullname: line.FullName})

File > Publish to the web

enter image description here

  1. Pick the tab you want
  2. Select csv as the published format
  3. Click Publish

And you will get back a public url to the csv

enter image description here

like image 150
Dave Bennett Avatar answered Oct 10 '22 04:10

Dave Bennett


The link you are using is not the file by itself, but the dropbox page to see the file :

$ curl -i --raw https://www.dropbox.com/s/6kibjeea5e4cks1/users.csv?dl=0
HTTP/2 302
server: nginx
date: Mon, 24 Jul 2017 14:46:44 GMT
content-type: text/html; charset=utf-8
content-length: 0
location: https://dl.dropboxusercontent.com/content_link/Z2KG0dzjBlHuMnIXyApZvBZFICVBXnLErAeLwlrkH46xnjg5yfd59ZfboKUpCNdo/file

You should try with the file direct link :

$ curl -i --raw https://dl.dropboxusercontent.com/content_link/Z2KG0dzjBlHuMnIXyApZvBZFICVBXnLErAeLwlrkH46xnjg5yfd59ZfboKUpCNdo/file
HTTP/2 200
server: nginx
date: Mon, 24 Jul 2017 14:47:46 GMT
content-type: text/csv; charset=utf-8
content-length: 231
like image 35
Gabriel Bleu Avatar answered Oct 10 '22 04:10

Gabriel Bleu