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.

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?

Comments

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)

3X_9_e_9e9fe8de6efeff8e15e6a5b8c4719e6e823c47c6.png

[Up] Anyone can help in this question ? I've create the database, but there are 60M of nodes so my solution is not so good.

jggomez
Graph Voyager

Hi,

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.

Thanks

Hello Juan,

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)
Version history
Last update:
‎10-17-2021 07:18 PM
Updated by:
Contributors