1
votes

I am trying to import two csv files into ArangoDB. One is created as document 'accounts' and the other as edge 'transactions'. For the accounts, it works. However, when importing the transactions data, errors occur. I try to import this csv file from my command prompt (windows 10) with the following code:

arangoimport --file transactions.csv --type csv --create-collection true -server.database AML --create-collection-type edge --collection transactions --translate "SENDER_ACCOUNT_ID =_from" --translate " RECEIVER_ACCOUNT_ID =_to"

In my data, the first row is the header, which includes TX_ID,SENDER_ACCOUNT_ID,RECEIVER_ACCOUNT_ID,TX_TYPE,TX_AMOUNT,TIMESTAMP,IS_FRAUD,ALERT_ID. And my original data looks like this: transactions

I know edges need _from and _to attributes. So, in my command line, I use "translate" to rename columns in the input file to _from and _to as the code above shows. But it still gives out the error message as follows:

error message

missing '_from' or '_to' attribute, offending document: {"TX_ID":17144,"_from":84,"_to":87, ... }

Could you please give me some hint what happen? I am struggling with this problem for hours and hours and have seen similar questions posted one month ago, but no answers. Hope someone could help me out. Thanks very much.

1
_from and _to are documents' _id values. The record that thrown the error should then be something like {"_from": "accounts/54", "_to": "accounts/87"}gurisko

1 Answers

2
votes

As gurisko pointed out in a comment, _from and _to must be valid document identifiers. That is, the name of a vertex collection, followed by a forward slash and the document key of a vertex, e.g. "accounts/87".

In the error message you can see that the attribute values are numbers, but must be strings with the collection name prepended. You don't have to modify the CSV file however, because arangoimport let's you prepend the collection name via the startup options --from-collection-prefix and --to-collection-prefix.

arangoimport --file transactions.csv --type csv --server.database AML --create-collection --create-collection-type edge --collection transactions --translate SENDER_ACCOUNT_ID=_from --translate RECEIVER_ACCOUNT_ID=_to --from-collection-prefix accounts --to-collection-prefix accounts

The imported documents should then look like so:

{ "TX_ID": 17144, "_from": "accounts/84", "_to": "accounts/87", ... }