LOAD CSV From a Local File Windows10

Hi guys, how are you doing?

I'm new in Neo4j and I'm facing some issues when loading data from a local file in a Windows 10 system to a sandbox instance of Neo4j 3.5

Basically the command is this:
LOAD CSV WITH HEADERS
FROM 'C:\Users\Renato\Desenvolvimento\laboratorios.csv'
AS row
RETURN trim(row.name), row.fundation, trim(row.companyId)

But it never ran. It keep sending over and over the same message:

Neo.ClientError.Statement.SyntaxError

Neo.ClientError.Statement.SyntaxError: Invalid input 's': expected four hexadecimal digits specifying a unicode character (line 2, column 11 (offset: 32)) "FROM 'C:\Users\Renato\Desenvolvimento\laboratorios.csv'"

I really don't get why it is expecting an unicode character here. Anyway, I don't know how to proceed and I have no http server to use as source of the file "laboratorios.csv".

If someone could give me a hand, I apreciate it.

Thanks.

I use Jupiter Notebook to upload for a CSV.

Link to my code for importing CSV.

1 Like

Hey Nicole, thanks for your response.

I understod that you creared a python code to upload data to your neo4j. Now I'm evaluating if neo4j would apply to my solution, and I really don't want to code (much). Do you know how to turn around this 'local file' issue using features from CYPHER or BOLT?

Howdy,

It would be helpful for us to see your import file. Here is a snippet of one of my import files for one of my databases that creates Genre nodes:

genre_id name genre_type multimedia_format_id
1 Audio Books Audio 1
2 Blues Audio 1

I prefer all my import files to be tab delimited.

My cypher call is as follows:

LOAD CSV WITH HEADERS FROM "File:///ld_genre.txt" AS row
FIELDTERMINATOR '\t'
CREATE (g:Genre {genre_id: TOINTEGER(row.genre_id), name: TRIM(row.name), genre_type: TRIM(row.genre_type), multimedia_format_id: TOINTEGER(row.multimedia_format_id)})
;

I hope this helps you in solving your issue.

~Alfonso

Hi Alfonso, sorry for the delay.

This is a sample of the data I am trying to upload (LOAD CSV). There is no other formatation in the file.

name,fundation,companyId
Laboratório 1,31/12/2010,##Laboratório140543
Laboratório 2,17/03/2007,##Laboratório239158

Howdy!

I will try to duplicate your error sometime with this short version in m y test database.

Let you know soon!
~Alfonso

Thanks Alfonso.

It seems to be the accented words, in Portuguese we have a lot of these. Anyway, I still don't know what is wrong.

I created a test CSV file and tested your script against my test database:

LOAD CSV WITH HEADERS FROM 'File:///laboratorios.csv' AS row RETURN trim(row.name), row.fundation, trim(row.companyId)

trim(row.name) row.fundation trim(row.companyId)
"Laborat�rio 1" "31/12/2010" "##Laborat�rio140543"
"Laborat�rio 2" "17/03/2007" "##Laborat�rio239158"

I did not duplicate your error--however, this produced the same issue I described in an open Topic for the same problem. I am running on OpenSuse and Neo4j. However, I will try again on my Windows box and see if I can get the same error you had.

P.S. I know that you can use MATCH and SET statements to correct characters in the database to replace the grey "diamond-?" symbols.

I got the same result as alfonso.martinez on my Windows 10 machine. No error.

Alfonso.

I noticed you used 'File:///laboratorios.csv' instead of 'C:\Users\Renato\Desenvolvimento\laboratorios.csv'. My opinion is that OPEN CSV is unable to locate a local file in my system.

Anyway, I apreciate your support to figure out what is going on here.

Thanks

What worked for me was the combination of the 'file:///filename.csv' AND the file being put into the Import folder within the database you are trying to populate. I found this info out here: How-To: Import CSV Data with Neo4j Desktop - Developer Guides

1 Like

Hi Sharon.

For now I am evaluating a sandbox instance of Neo4j, and that's what I think is causing the issue. See, I am trying to upload a file from my local system to this sandbox instance through a browser using LOAD CSV and seems that the browser is not able to locate the file properly.

I will read this info you sent me.

True...I used Linux in my testing, which is my primary OS; hence, the process is the same regardless the OS used for Neo4j. Sharon provided a good resource; I prefer using the manual myself. Refer to LOAD CSV - Cypher Manual.

Good luck!

Alfonso, Sharon.

You are great, both of you. I made a small search in Google and found this video Neo4j Sandbox: Google Spreadsheets/Drive Integration - YouTube explainng how to upload data from Google Sheets.

This is how I go.

Thank you very much fellows.

1 Like