2
votes

I'm just getting started with Neo4j, and have been trying to create my first project in Neo4j Community with a small sample data from a CSV. I keep getting an invalid input/syntax error (see image below).

The problem could be several places:

  1. I may not have set up my project correctly
  2. I may not have the file in the right place
  3. I may not be using the syntax correctly

Here is the Cypher I've been using to try to load the file:

LOAD CSV WITH HEADERS FROM 'C:\Users\Diana\Documents\Nattosphere\Natto_Sample.csv' AS line
CREATE (n: Natto_Variety{Product_UID: line.Product_UID, Product_Manufacturer: line.Product_Manufacturer, Product_Weight_g: line.Product_Weight_g, Product_Flavoring: line.Product_Flavoring})   

I've tried several approaches, and created a simplified file, but am getting the same error each time:

Invalid input 's': expected org$neo4j$cypher$internal$compiler$v2_2$parser$Strings$$HexDigit (line 1, column 33 (offset: 32))
"LOAD CSV WITH HEADERS FROM 'C:\Users\Diana\Documents\Nattosphere\Natto_Sample.csv' AS line"

At the bottom of the GUI, another error reads:

"Neo.ClientError.Statement.InvalidSyntax"

Any idea what might be happening here?

-D

4

4 Answers

0
votes

I think you have to do:

LOAD CSV WITH HEADERS FROM 'file:C:/Users/Diana/Documents/Nattosphere/Natto_Sample.csv' 

If that doesn't work try:

LOAD CSV WITH HEADERS FROM 'file://C:\Users\Diana\Documents\Nattosphere\Natto_Sample.csv' 

See: http://neo4j.com/developer/guide-import-csv/

0
votes

Frist, you have to set true in setting dbms.security.allow_csv_import_from_file_urls

Second, you must to set where neo4J will search the csv in dbms.directories.import

When you setting those items, you have to copy you csv file into the folder where we set the dbms.directories.import

Later in Cypher:

LOAD CSV FROM 'file:///Natto_Sample.csv'

*if you hace folder into folder... use this character / to route your URL

0
votes

The Syntaxe to load the csv with headers as described In the CSV Import Guide is :

LOAD CSV WITH HEADERS FROM "file-url" AS line

where the file-url , for local files, is :

file:///data.csv 


Put the csv file in the import directory,and that should works

-1
votes

You don't need to write the C: reference:

LOAD CSV WITH HEADERS FROM 'file:/Users/Diana/Documents/Nattosphere/Natto_Sample.csv'