I need to create company and parent company relations from a json file, however some companies do not have parent companies, like this example
{ "company_id" : 2032,
"parent_company_id" : 343
}
{ "company_id" : 2332,
"parent_company_id" :
}
It is possible to create company-paranet company relation when a company has parent company, skip the company if it does not have parent company or substitute null with some characters?
Thanks.
call apoc.load.json("file:///testjson.json")
yield value AS row
WITH row where row.parent_company_id<>0
MERGE(c:Company{companyId:row.company_id})-[:HAS_PARENT]->(pc:Company{companyId:row.parent_company_id})
RETURN c,pc
Below is the output :
Please let me know if this is what you need or did I miss anything.