Elmar Taghizade
Elmar Taghizade

Reputation: 1

Can't import csv to neo4j

My code:

LOAD CSV FROM "C:\Users\Elmar\Desktop\tmp-raise.csv" AS line 
WITH line 
RETURN line

The error that it gives: Invalid input ':': expected 'o/O' (line 1, column 18 (offset: 17)) "LOAD CSV FROM "C:\Users\Elmar\Desktop\tmp-raise.csv" AS line" ^

I have also tried:

USING PERIODIC COMMIT 10000 
LOAD CSV FROM ""C:\Users\Elmar\Desktop\tmp-raise.csv" AS line
WITH line
RETURN line

What is the problem? Can anyone help me?

Upvotes: 0

Views: 1113

Answers (2)

user3805507
user3805507

Reputation: 31

Load csv from "file:///C:/xyz.csv" as line
return line

The above code works well. But do comment out the configuration

dbms.directories.import=import

in the settings.

Other solution is you can drop a (.txt, .cyp, .cql) file in the drag to import box.

Upvotes: 0

InverseFalcon
InverseFalcon

Reputation: 30417

According to the CSV import guide, your path should be prefixed with file: and should use forward slashes. The example path given in the guide for windows is file:c:/path/to/data.csv (though I have seen example paths starting with file://). Give this a try:

USING PERIODIC COMMIT 10000 
LOAD CSV FROM 'file:c:/Users/Elmar/Desktop/tmp-raise.csv' AS line
WITH line
RETURN line

If that doesn't work, give it a try with file:// as the path prefix.

EDIT: Looks like CSV loads use a relative path from the default.graphdb/import folder. I had thought that was for Mac/Unix only, but it looks like Windows does the same. If you move CSVs you want to import into the import folder, you should be able to load them using file:///theFileName.csv

Upvotes: 1

Related Questions