I'm using Neo4j 2.2.3 and have tried to import a CSV file with Cypher's LOAD CSV that looks like this:
PRODUCT_ID,PRODUCT_DESC,PRODUCT_TYPE
99,"A","X"
999,"B","X"
9999,"C","Y"
99999,"D","Y"
However, I'm having difficulty with the custom ID. Neo4j does not import them.
The PRODUCT_ID
column is a unique ID that comes from a different system (over which I have no control) but, suffice to say, it's not a row number. The PRODUCT_ID
is required to match data from other files.
When I look at the file I see all fields:
LOAD CSV WITH HEADERS FROM 'file:///path/to/product.csv' AS row
RETURN row
The same is true when I pick any of the columns except PRODUCT_ID
:
LOAD CSV WITH HEADERS FROM 'file:///path/to/product.csv' AS row
RETURN row.PRODUCT_DESC
When I use RETURN row.PRODUCT_ID
instead, I get a table of nulls.
Similarly, this does not work:
LOAD CSV WITH HEADERS FROM 'file:///path/to/product.csv' AS row
CREATE (p:Product { id: toInt(row.PRODUCT_ID),
name: row.PRODUCT_DESC,
type: row.PRODUCT_TYPE })
I get the products with descriptions and types, but the IDs are lost. I need the IDs to match this CSV file with other files, but I'm stuck and would appreciate some help. I haven't seen any restrictions regarding ID columns in the documentation.
When I move the PRODUCT_ID
column away from the first position, it works with the caveat that the then-first column is ignored. So, if I make PRODUCT_ID
the last column, PRODUCT_DESC
is null. Is it necessary to have row numbers as the first column in a CSV? Seems odd.
Any suggestions?