Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-14-2019 11:00 AM
Hello guys,
I'm trying to load a data from a CSV file containing the following fields (header), as shown in the figure below:
This CSV contains sales information of a specific store (CODIGOFILIAL). A person (CPF) can buy some products (CODIGOPRODUTO) that can be attached to the same basket (NUMEROUNICOCUPOM), which was bought in a specific date (DATAMOVIMENTO); as you can see on the highlighted text.
I'm trying to create the graph using the following cypher command:
LOAD CSV WITH HEADERS FROM 'file:///subset_vendas_cupom.csv' AS line
MERGE (n:Cliente {cpf:line.CPF})
MERGE (m:Cupom {codigoCupom:line.NUMEROUNICOCUPOM, dataMovimento:line.DATAMOVIMENTO})
MERGE (o:Produto {codigoProduto:line.CODIGOPRODUTO})
MERGE (p:Filial {filial:line.CODIGOFILIAL})
MERGE (n)-[:FEZ_PEDIDO]->(m)-[:CONTEM]->(o)-[:VENDIDO]->(p)
The problem is that it creates multiple relationships from a client to the same basket, because the basket contained several items which appear in different rows of my CSV file; as follows:
How can I make the highlighted relationships unique? Thanks in advance.
02-14-2019 11:53 AM
Solved this by separating the MERGE (n)-[:FEZ_PEDIDO]->(m)-[:CONTEM]->(o)-[:VENDIDO]->(p)
into small pieces.
02-16-2019 06:34 PM
Great that you solved the issue.
The basic rule of thumb is that MERGE will create the entire pattern of the pattern doesn’t already exist in its entirety.
All the sessions of the conference are now available online