Search code examples
neo4jneo4j-apoc

Neo4j ERROR (Neo.ClientError.Procedure.ProcedureCallFailed)


I am new to Neo4j. I tried to create "Account" nodes and "Trade_History" relations at the same time using apoc.import.csv.

CALL apoc.import.csv(
            [{fileName: "file:///Account.csv", labels: ['Account']}],
            [{fileName: "file:///Trade_History.csv", type: 'TRANSACTION'}],
            {}
)

However, I received the following error message.

Neo.ClientError.Procedure.ProcedureCallFailed Failed to invoke procedure apoc.import.csv: Caused by: java.lang.IllegalStateException: Node for id space __CSV_DEFAULT_IDSPACE and id xxxxxxx not found

I think the error is that the id "xxxxxxx" is not found, but which id, Account or Trade_History, is missing? Is there an ID that exists in Trade_History that does not exist in Account? If so, is it possible to implement any way to skip (not create a relationship) if the Trade_History ID pair does not exist in the Account? Or, If you know of another candidate query, it would be appreciated.

This might be basic, but could you tell me some advice? Thank you in advance.


P.S. The first three lines of Account.csv and Trade_History.csv are as follows;

Account.csv

:ID,name
000000000080,James
000000000056,Kevin
000000000039,Thomas

Trade_History.csv

LABEL:STRING,ACCOUT:START_ID,ACCOUT:END_ID
XYZ36417771,AAA_20670095845, 047316281
XYZ56315967,BBB_0000970982, 456317783746
XYZ61489917,CCC_00209200036399,093891638

Solution

  • Your IllegalStateException occurs because "xxxxxxx" occurs as a value in either the :START_ID or :START_ID column in your relationships file Trade_History.csv. Ideally, you should cleanse your data before you do an import. For example:

    • If your node ID values are supposed to be numeric strings, verify that the :START_ID or :START_ID values are all numeric strings. For each violation, figure out how to fix the data or remove that row.
    • Remove extraneous spaces (like the one at the start of " 047316281"). That can be another cause of errors in CSV files.

    Another observation is that you are using the syntax for defining ID spaces in your relationship file, whereas ID spaces can only be defined in a node file. That is, your relationship file is not supposed to have "ACCOUT" in ACCOUT:START_ID and ACCOUT:END_ID (it does not cause an error, but the bad syntax should be fixed to avoid confusion and possible future issues). If you really need ID spaces (and you wouldn't if you only have one node file), then you should read and follow the documentation.