Neo4J Load CSV -> URI is not hierarchical - neo4j

I try to import CSV in a Neo4j Database and I have a problem.
On my desktop computer (windows 7, java 1.8.0_40-b25), the LOAD CSV works great.
But on the server (windows 2012 R2, java 1.8.0_65-b17), i have this error message "URI is not hierarchical".
I try to put the data on C:, F: ... no change.
Here's the code :
USING PERIODIC COMMIT 100
LOAD CSV WITH HEADERS FROM
"file:F:/Neo4JData/Destination.csv"
AS line
MERGE (d:Destination {`Code`: line.`Code`});
Thanks for your help.

Are you using 2.3.0 Community Edition?
try:
USING PERIODIC COMMIT 10000 LOAD CSV FROM
'file:///F:\\Neo4JData\\Destination.csv

Create an import folder in the default path of the DB and place the file there that helped me.
For example: C:\Users\XXXXY\Documents\Neo4j\default.graphdb\import and put the csv there. In the query use
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///customers.csv" AS row
CREATE (:Customer {companyName: row.CompanyName, customerID: row.CustomerID, fax: row.Fax, phone: row.Phone});

I had the same problem. I solved it by putting /// instead of F:/ or F:///.
So if your source is
F:/FolderOne/FolderTwo/file.csv
It becomes
///FolderOne/FolderTwo/file.csv
Remember that in order to add the file you must put file: in front of the source.
So finally
file:///FolderOne/FolderTwo/file.csv

As specified above once you try with
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///E:/AdventureWorks/adventureworks-neo4j/data/products.csv" as row
CREATE (:Product {productName: row.ProductName, productNumber: row.ProductNumber, productId: row.ProductID, modelName: row.ProductModelName, standardCost: row.StandardCost, listPrice: row.ListPrice});
The "URI is not hierarchical" error disappears. Then most probably you will get an error saying that it couldnt load the resource like
TransientError.Statement.ExternalResourceFailure
In order to solve the same you should find the neo4j.conf file.
Since i'm using a windows 10 machine and community edition of neo4j i could find the same in the below path.
C:\Users\{username}\AppData\Roaming\Neo4j Community Edition
Edit the conf file and comment out the line
dbms.directories.import=import
Doing the above steps enabled me to load the csv file.

The file path seems wrong, can you try with :
"file:F:///Neo4JData/Destination.csv"

Try with:
file:///F:/Neo4JData/Destination.csv

Putting the .csv into the $NEO4JHOME/default.graphdb/import directory worked. You may have to create the folder, or maybe uncommenting the dbms.directories.import=import line in conf might do it. I dunno, did it the hard way :)
However, I found that I still had to include the drive specifier, i.e., file:///c:\csv2import.csv even if it wasn't in the root but in the import directorry

Use the path 'file:///F:/Neo4JData/Destination.csv' and add the Destination.csv file to the neo4jDB\import directory.If the import directory is not there create a new directory named as import and add the file.

Create a folder import under default.graphdb and place your csv files there. Later, you can use file:///fileName.csv in your LOAD CSV query

I was getting this problem as well so what I did was to copy the folder in which the .csv file was present to the following location:
C:\Users\Username\AppData\Roaming\Neo4j Desktop\Application\neo4jDatabases\database-27badd10-8989-482d-871b-cad746091f07\installation-3.3.3\import\
it seems when neo4j is installed and we try to import data from files by giving "file:///c://........" then neo4j starts looking for that file in the location C:\Users\Username\AppData\Roaming\Neo4j Desktop\Application\neo4jDatabases\database-27badd10-8989-482d-871b-cad746091f07\installation-3.3.3\import\
i.e the import folder. So we have to copy all the files needed to be imported by this this type of statement in that import folder.

This one worked at my end in windows
LOAD CSV FROM 'File:///order-details.csv' AS row
RETURN count(row);

Related

Neo4j import tool fails and doesn't show why

I have created 15.4 GB of csv files that I would like to import into fresh new Neo4j graph.db.
After executing neo4j-admin import --delimiter="|" --array-delimiter="&" --nodes="processes.*" command (I have 17229 csv files, that are named "processes_someHash.csv") I get this particular output:
..../pathWithCsvFiles: neo4j-admin import --delimiter="|" --array-delimiter="&" --nodes="processes.*"
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
For input string: "10059167292802359779483"
usage: neo4j-admin import [--mode=csv] [--database=<name>]
[--additional-config=<config-file-path>]
[--report-file=<filename>]
[--nodes[:Label1:Label2]=<"file1,file2,...">]
[--relationships[:RELATIONSHIP_TYPE]=<"file1,file2,...">]
[--id-type=<STRING|INTEGER|ACTUAL>]
[--input-encoding=<character-set>]
[--ignore-extra-columns[=<true|false>]]
[--ignore-duplicate-nodes[=<true|false>]]
[--ignore-missing-nodes[=<true|false>]]
[--multiline-fields[=<true|false>]]
[--delimiter=<delimiter-character>]
[--array-delimiter=<array-delimiter-character>]
[--quote=<quotation-character>]
[--max-memory=<max-memory-that-importer-can-use>]
[--f=<File containing all arguments to this import>]
[--high-io=<true/false>]
usage: neo4j-admin import --mode=database [--database=<name>]
[--additional-config=<config-file-path>]
[--from=<source-directory>]
environment variables:
NEO4J_CONF Path to directory which contains neo4j.conf.
NEO4J_DEBUG Set to anything to enable debug output.
NEO4J_HOME Neo4j home directory.
HEAP_SIZE Set JVM maximum heap size during command execution.
Takes a number and a unit, for example 512m.
Import a collection of CSV files with --mode=csv (default), or a database from a
pre-3.0 installation with --mode=database.
options:
--database=<name>
Name of database. [default:graph.db]
--additional-config=<config-file-path>
Configuration file to supply additional configuration in. [default:]
--mode=<database|csv>
Import a collection of CSV files or a pre-3.0 installation. [default:csv]
--from=<source-directory>
The location of the pre-3.0 database (e.g. <neo4j-root>/data/graph.db).
[default:]
--report-file=<filename>
File in which to store the report of the csv-i
... and more of a manual
What does the For input string: "10059167292802359779483" mean?
Have you checked the headers in your CSV files? That's been a problem for me when importing previously.
Any chance your delimiter character is also appearing in data values?
well, I tested neo4j importing with more compact dataset and it worked fine (when there was problem with delimiter for example, then the error message showed me what was the specific problem). I optimized my program for creating these csv files based on this low dataset and used it to make the mentioned bigger csv files, which doesn't work.

Neo4j LOAD CSV not working when I use link from github

I have this piece of code which loads a csv from another site.
LOAD CSV FROM 'https://www.quackit.com/neo4j/tutorial/genres.csv' AS line
CREATE (:Genre { GenreId: line[0], Name: line[1]})
But when I upload the same csv to my github account and try it, it gives me an error.
LOAD CSV FROM 'https://www.quackit.com/neo4j/tutorial/genres.csv' AS line
CREATE (:Genre { GenreId: line[0], Name: line[1]})[![enter image description here][2]][2]
I only changed the link and nothing else. How do I resolve this?
You need to use the RAW version of the file.
On your github repo, click on your genres.csv file and then click on RAW
Then copy the url and use it in your LOAD CSV command :
https://raw.githubusercontent.com/JP-Reddy/Recommendation-Engine/master/genres.csv

Neo4j Importing local CSV File

I'm trying to import a local csv file but I have got InvalidSyntax Error.
LOAD CSV WITH HEADERS FROM file:C:/csv/user.csv
Invalid input '/' (line 1, column 35 (offset: 34))
"LOAD CSV WITH HEADERS FROM file:C:/csv/user.csv"
You need to put the filename in quotes, and add a few more slashes:
LOAD CSV WITH HEADERS FROM "file:///C:/csv/user.csv"
Full documentation here.
The command below will return the first 5 lines of your CSV file:
LOAD CSV WITH HEADERS FROM "file:///<PATH_TO_YOUR_CSV_FILE>" AS line WITH line RETURN line LIMIT 5;
But you'll have to follow some steps to align with Neo4J security restrictions.
1) Find the conf folder in the neo4j server folder.
Open the neo4j.conf with a text editor.
2) Uncomment the line containing:
#dbms.security.allow_csv_import_from_file_urls=true
To uncomment it, just remove #. It should be like this:
dbms.security.allow_csv_import_from_file_urls=true
3) Comment this line below:
dbms.directories.import=import
To comment it, add #. It should be like this:
#dbms.directories.import=import
Further on importing from CSV in neo4j documentation here: https://neo4j.com/blog/importing-data-neo4j-via-csv/
LOAD CSV WITH HEADERS FROM "file:C:/path/location/filename.csv" AS row
Found that these query asks Neo4j to look in a specific location
C:\Users\*******\.Neo4jDesktop\neo4jDatabases\database-2b9d81ff-1976-427e-ba98-4f3191c3ef62\installation-3.4.9\import
placing your csv here and using the query
LOAD CSV WITH HEADERS FROM "file:///testData2.csv" AS line
solved the issue for me
or you can change the settings by making changes here
dbms.directories.import=import
NB: I am using windows 10 , neo4j-desktop-offline-1.1.12
I had the same problem (in Windows 10) and I realized that I was just trying to load the CSV file without saying to it to return something.
For me it worked pretty well like this:
LOAD CSV WITH HEADERS FROM "file:///C:all_data.csv" AS line
RETURN line
Note: Do not forget to place the CSV file that you want to import on the neo4j import file!

Neo4j - Syntax for Loading CSV with Headers

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:
I may not have set up my project correctly
I may not have the file in the right place
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
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/
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
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
You don't need to write the C: reference:
LOAD CSV WITH HEADERS FROM 'file:/Users/Diana/Documents/Nattosphere/Natto_Sample.csv'

Team Foundation Build Activitie "DownloadFiles" is giving error

I am customizing the default build process template in TFS 2010.
i am using "DownloadFiles" build activity and in server path i have given "$/TFS/Libraries/Foo.DLL", when i run the execute definition its throwing error as "Access to the path '\ServerName\SharedFolder\BuildName\TempFolder' is denied.".
But when i give server path as "$/TFS/Libraries" its downloading all the files in Libraries folder into shared TempFolder.
But i need do download only one file. Please help..
Thanks in advance..
Now, DownloadFiles does work for a whole folder only:
ServerPath="$/proj/path" - works great, all is downloaded to LocalPath.
ServerPath="$/proj/path/name.ext" - borked.
I've de-compiled DownloadFiles to see why: First it gets a list of server items, in our case just $/proj/path/name.ext. Then, it calculates the local path like this:
localItemPath = Path.Combine(LocalPath,VersionControlPath.MakeRelative(ServerItem, ServerPath));
In this line, the activity assumes that ServerPath is a path. If it's not, then MakeRelative will not recognize it, and the local path will be LocalPath/$/proj/path/name.ext, as the OP has observed.
Also, if ServerPath is not canonical - for example, $/proj/path/../path2, the same will happen. Solution: use VersionControlPath.GetFullPath(myNonCanonicalPath).
You need to grant the user running the build service with write permissions on the shared folder.
http://msdn.microsoft.com/en-us/library/cc668757.aspx
There are two separate Build activities, DownloadFiles for a folder ServerItem and a DownloadFile for a single file ServerItem.I'd expect it should work with DownloadFile.

Resources