Neo.ClientError.Statement.SyntaxError When Importing CSV File

Hi

When I attempt to import my CSV using;

LOAD CSV WITH HEADERS FROM "file:///male bounce.csv"

I receive the following error;

Neo.ClientError.Statement.SyntaxError

Invalid input '': expected "!=" "%" "*" "+" "-" "/" "::" "<" "<=" "<>" "=" "=~" ">" ">=" "AND" "AS" "CONTAINS" "ENDS" "IN" "IS" "OR" "STARTS" "XOR" "^" "||" (line 1, column 53 (offset: 52)) "LOAD CSV WITH HEADERS FROM "file:///male bounce.csv"" ^

P.S. I've imported the csv file into the import section.

Hello, is that your full query?
If that's the case, LOAD CSV is not sufficient, you will need to do something the loaded data and persist it to the graph: LOAD CSV - Cypher Manual

Hi!

Yes this is my full query.. I also should have added that Iā€™m completely new to neo4j / cypher coding so any help is greatly appreciated.

@colm.odonaghue2

your csv file has a space in its name? correct?

try

LOAD CSV WITH HEADERS FROM 'file:///male%20bounce.csv' as row return row

Hi

I ran this line of code and I the following error;

Neo.ClientError.Statement.ExternalResourceFailed

Cannot load from URL 'file:///male%20bounce.csv': configuration property 'dbms.security.allow_csv_import_from_file_urls' is false ()

From looking on Stack Overflow it appears that If I want to load files from other directories, I have to allow that in neo4j.conf and that I must find the neo4j.conf file for my Neo4j installation. However, I'm using a free instance online via neo4j Aura and didn't install it locally as such

In that case, you need to do something like:

LOAD CSV WITH HEADERS FROM 'file:///male%20bounce.csv' AS row
MERGE (:ANode {aProperty: row.property})

What happens after the first line completely depends on:

  1. the CSV data (in this example, we assume one column is named property)
  2. what you want to persist in the graph (in this example, I only upsert a node with a ANode label and a single property called aProperty)

You can of course persist an arbitrary graph based on the loaded data.

May I suggest you have a look at the free courses at https://graphacademy.neo4j.com/? This will help you get up to speed in no time.

@colm.odonaghue2

Thank you for this detail and that we are now learning this a Neo4j Aura instance.
Neo4j Aura does not allow access to files at the file system and to which file:/// suggest reading files from the filesystem. So file:/// is not going to be an option. in this case you will need to have load csv read from a http:// location/resource

1 Like