Hi,
I'm trying to produce my first project in Neo4j and i've some questions with the start.
I have the this CSV structure.
Country A, Country B, Year, Sold Cars.
So i've the relationship cars sold between the countries in the year;
The country A sell cars to B and B to A.
There is more than one sales record from country A to country B in year X.
In your opinion, how is the best way to produce this graph and find the most prominent countries?
I create this code to my dataframe and the result is in the end of the message. But
i need to join export into a single value just for each direction. Could someone help me with this issue?
:auto USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM "file:///comtrade_sample.csv" AS dados
WITH dados
WHERE dados.origin IS NOT NULL
MERGE (n:Pais {Name:dados.origin})
MERGE (m:Pais {Name:dados.dest})
MERGE (n) -[:export {export:coalesce(toInteger(dados.export_val), 0)}] -> (m)
60M of nodes is strange because there are not 60M of countries. Could you review the country names should be the same? The merge command searches if there are other nodes with the same property and value then if the node doesn't exist, it is created.
Yes, it's a mistake, i've 60M of relationship and +- 220 nodes (some islands count like a countries) ...
Now my code work like i nedd. Tks
:auto USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM "file:///comtrade_sample.csv" AS dados
WITH dados
WHERE dados.origin IS NOT NULL
MERGE (n:Pais {Name:dados.origin})
MERGE (m:Pais {Name:dados.dest})
MERGE (n) -[r:export] -> (m)
ON CREATE SET r.weight = coalesce(toInteger(dados.export_val), 0)
ON MATCH SET r.weight = r.weight + coalesce(toInteger(dados.export_val), 0)