Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-22-2020 01:03 AM
Hi,
I have a same dataset using
"""LOAD CSV WITH HEADERS FROM 'file:///{}' AS row
CREATE(n:{})
SET n=row;""".format(source_path+file_name,table_name)
the above query i have done initial load of dataset.
for the second load (in which i have few new records+updated records) from existing table,
how could i load the second set of data into the same table.
I tried to use match and merge query.
"""LOAD CSV WITH HEADERS FROM 'file:///{}' AS row
WHERE row.customer_id IS NOT NULL
MERGE(c:initial_load_customer
{customer_id:row.customer_id})""".format(source_path+file_name)
i got an error message as
Traceback (most recent call last):
File "C:/Users/lenovo/PycharmProjects/header comparison/csv_neo4j.py", line 27, in
MERGE(c:initial_load_customer {customer_id:row.customer_id})""".format(source_path+file_name)
KeyError: 'customer_id'
Do my second load query is wrong or else is there any way i can create a node if id doesnt exist, else if node exist update(update all the columns with values in recent file) the node with property available in csv file.
09-27-2020 10:23 PM
Merge actually creates a node if it doesn't exists; in the merge statement you also can specify data modification on required action, please check neo4j merge documentation - https://neo4j.com/docs/cypher-manual/current/clauses/merge/
Your last query seems arises from pandas, but not from neo4j insertion. Could you please confirm it?
All the sessions of the conference are now available online