1
votes

Am I correct that one cannot use cypher to load a csv file with header together with datatype? (By "with datatype", I mean header with something like this: For entities:

orderId:ID(Order) customerId:IGNORE

For relationships:

:START_ID(Order) :END_ID(Product) )

According to this two websites: https://neo4j.com/developer/guide-import-csv/, http://jexp.de/blog/2015/04/how-to-neo4j-data-import-minimal-example/ It seems that I could import data together with header in this way in either powershell or command prompt (I am using a windows computer):

path\to\neo4j-community-3.1.1\bin\neo4j-import --into graph.db  \
--nodes:Person C:\SavedNewest\people_header.csv, C:\SavedNewest\people.csv  \
--relationships:KNOWS C:\SavedNewest\friendships_header.csv,C:\SavedNewest\friendships.csv

(The csv are reconstructed according to this website: http://jexp.de/blog/2015/04/how-to-neo4j-data-import-minimal-example/)

Error from PowerShell:

At line:2 char:3
+ --nodes:Person C:\SavedNewest\people_header.csv,https://gist.githubus ...
+   ~
Missing expression after unary operator '--'.
At line:2 char:3
+ --nodes:Person C:\SavedNewest\people_header.csv,https://gist.githubus ...
+   ~~~~~~~~~~~~
Unexpected token 'nodes:Person' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator

Error from Command prompt:

WARNING: This command does not appear to be running with administrative rights.
  Some commands may fail e.g. Start/Stop
WARNING: neo4j-import is deprecated and support for it will be removed in a future
version of Neo4j; please use neo4j-admin import instead.

Input error: Expected '--relationships' to have at least 1 valid item, but had 0 []
Caused by:Expected '--relationships' to have at least 1 valid item, but had 0 []
java.lang.IllegalArgumentException: Expected '--relationships' to have at least 1 valid item, but had 0 []
        at org.neo4j.kernel.impl.util.Validators.lambda$atLeast$6(Validators.java:125)
        at org.neo4j.helpers.Args.validated(Args.java:640)
        at org.neo4j.helpers.Args.interpretOptionsWithMetadata(Args.java:608)
        at org.neo4j.tooling.ImportTool.extractInputFiles(ImportTool.java:508)
        at org.neo4j.tooling.ImportTool.main(ImportTool.java:389)
        at org.neo4j.tooling.ImportTool.main(ImportTool.java:334)

What is the cause of error and how should I load a csv file with header and data type correctly?

Edit: New Input for cmd:

C:\Users\tsutomu\Desktop\MSS\Bachelorarbeit\neo4j-community-3.1.1\bin\neo4j-import --into graph.db  --nodes:Person "file:c:/SavedNewest/people_header.csv,file:c:/SavedNewest/people.csv" --relationships:KNOWS "file:c:/SavedNewest/friendships_header.csv,file:c:/SavedNewest/friendships.csv"

The Error:

Input error: Directory of file:c:\SavedNewest\people_header.csv doesn't exist

Caused by:Directory of file:c:\SavedNewest\people_header.csv doesn't exist java.lang.IllegalArgumentException: Directory of file:c:\SavedNewest\people_header.csv doesn't exist at org.neo4j.kernel.impl.util.Validators.matchingFiles(Validators.java:48) at org.neo4j.kernel.impl.util.Converters.lambda$regexFiles$7(Converters.java:76) at org.neo4j.kernel.impl.util.Converters.lambda$toFiles$8(Converters.java:95) at org.neo4j.helpers.Args.interpretOptionsWithMetadata(Args.java:608) at org.neo4j.tooling.ImportTool.extractInputFiles(ImportTool.java:508) at org.neo4j.tooling.ImportTool.main(ImportTool.java:388) at org.neo4j.tooling.ImportTool.main(ImportTool.java:334)

Same error for powershell.

The path of people_header.csv: C:\SavedNewest\people_header.csv Is there anything I should add to environmental path?

1

1 Answers

0
votes

You have a couple of issues in your command line:

  1. You cannot have embedded spaces in your command line arguments. For example, C:\SavedNewest\people_header.csv, C:\SavedNewest\people.csv should be a single argument, so you need to either remove the space after the comma or double-quote the entire argument.

  2. The file path URLs must be formatted appropriately. To quote from the developer guide:

    Make sure to use the right URLs esp. file URLs.+ On OSX and Unix use file:///path/to/data.csv, on Windows, please use file:c:/path/to/data.csv