cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Non Matching Records from CSV / Neo: Using Load CSV

Kailash
Graph Buddy

Team,

I am trying to load the data from csv. I just want to right now list the non matching records.

  1. one which are not there in neo4j but are there in csv
  2. the one which are there in neo but not there in the CSV.

Could there be a simple query?

Query below will give matching ones.
< LOAD CSV WITH HEADERS FROM "file:///mydetails.csv" AS records FIELDTERMINATOR ',' WITH records WHERE not records.PersonId IS NULL match (p:Person{Id:records.PersonId)}) return p.Id, records.PersonId limit 10000 />

thanks,
Kc

3 REPLIES 3

Kailash
Graph Buddy

Below Query will give the non matching but is it ok or we have a different way?

<
LOAD CSV WITH HEADERS FROM "file:///mydetails.csv" AS records FIELDTERMINATOR ',' WITH records WHERE not records.PersonId IS NULL optional match (p:Person{Id:records.PersonId)}) with records.PersonId as csvPersonId , p.Id as personNeoId, count(records) as csvcount, count(p) as count
with csvPersonId where count = 0
return csvPersonId

/>

@Kailash

but is the goal then if the record exists in neo4j then update the record otherwise create the record?

if so see MERGE - Neo4j Cypher Manual and subsequent functionality described on the page

Kailash
Graph Buddy

Yes, with merge we can create the missing . using on match and on create with merge.
But right now goal is just to compare the two, we are trying to find out missing records so.