Neo4j admin import relationship

Hi there,
I am trying to import a large dataset consists of 8 CSV files using admin import but I am facing difficulty on how to create relationships among them.

Here is the explanation of the CSV files.

  1. Addresses.csv. consists of two columns
    addID, address
  2. users.csv addID, userID.
  3. Transaction.csv
    txID, blockID,n_inputs, n_outputs
  4. Incoiming Transaction.csv
    txID, addID, value.
  5. Outcoming Transaction.csv
    txId, addID, value.
  6. Hash Transaction.csv
    txID, hash
  7. Transaction Time.
    txID, unixtim
  8. Balances.csv
    addID, balance

I want to create relationships among them based on the addID and txID exist in each file.
Note that, I create a header of each file in a separate CSV file. I was able to successfully create the addresses and users relationship using:

neo4j-admin import --id-type=STRING \ 
  --nodes:User="import/users-header.csv,import/users.csv" \ 
  --nodes:Address="import/addresses-header.csv,import/addresses.csv" \ 
  --relationships:PARTOF="import/partof-header.csv,import/users.csv,import/addresses.csv" \ 
  --ignore-missing-nodes=true \ 
  --ignore-duplicate-nodes=true \ 
  --high-io=true 

and the partof-header.csv is as following:
START_ID(Address),:END_ID(User) ,

the addresses-header is

addID:ID(Address),address

and users-header is

addID:IGNORE,userID:ID(User)

but when it comes to other files, I faced difficulty to create the relationship.

Can anyone guide me on how to create relationships based on their IDs.

Does anyone have any suggestions on how I could do this more efficiently?

Many thanks,
Khaled

I think you could do that like this:

neo4j-admin import --id-type=STRING \ 
  --nodes:User="import/users-header.csv,import/users.csv" \ 
  --nodes:Address="import/addresses-header.csv,import/addresses.csv" \ 
  --relationships:PARTOF="import/partof-header.csv,import/users.csv,import/addresses.csv" \ 
  --relationships:ADDRESS="import/address-header.csv,import/Incoiming Transaction.csv" \ 
  --ignore-missing-nodes=true \ 
  --ignore-duplicate-nodes=true \ 
  --high-io=true 

where import/address-header.csv contains the following:

:START_ID(Transaction),:END_ID(Address),value

You can process the CSV multiple times to create different parts of the graph.

Does that make sense/work for you?

1 Like

Sorry for late reply, Thank you for replying me
I have already successfully loaded the files into neo4j by assigning the files that contain the primary keys in the node and the files contain foreign keys in the relationship.
I first match the files that have only addID and txID with the files that have primary keys in the node using Emeditor, then i used the following codes to process the data.

neo4j-admin import --id-type=STRING ---nodes:User="import/users-header.csv,import/user.csv" --nodes:Address="import/addresses-header.csv,import/addresses.csv" --nodes:Txhash="import/txhash-header.csv,import/txht.csv" --relationships:PARTOF="import/partof-header.csv,import/user.csv,import/addresses.csv" --relationships:TO="import/incoming-header.csv,import/txin.csv" --relationships:SENDING="import/outcoming-header.csv,import/txout.csv" --ignore-missing-nodes=true --ignore-duplicate-nodes=true --high-io=true

1 Like