How to specify a separate header file inside apoc.load.csv?

Viewed 113

I'm migrating data from RDBMS to Neo4j. I'm using 'neo4j-admin import' tool for bulk import by loading a csv dump. In order to accomodate live updates, I'm again getting the csv dump from RDBMS. Now, I'm using 'apoc.load.csv'.

I've my data in one file, say 'upd_product.csv' And I've the headers in 'product_h.csv'

Now I want to use apoc.load.csv

Call apoc.load.csv('/upd_product.csv') yield map, list
Match (p: Product {id: line[0]})
Set p = map

In order to have this map, I need to specify the headers, and there exists no documentation on how to do that.

Please help me in this context. Thanks in advance.

1 Answers

Just prepend the contents of product_h.csv (presumably a single line) to the beginning of upd_product.csv. Afterwards, you can just do this (assuming the header value for the first column is id):

CALL apoc.load.csv('/upd_product.csv') YIELD map
MATCH (p:Product {id: map.id})
SET p = map
Related