-
Notifications
You must be signed in to change notification settings - Fork 38
CSV Importer
SYSTOPIA edited this page Jun 10, 2013
·
1 revision
The CSV-Importer plugin can import bank transactions (BTX) into CiviBanking from arbitrary CSV files. It uses a configurable set of rules to map the data found in the CSV to the fields needed for BTXs.
Like all plugins, the CSV-Importer takes a JSON string as configuration. Valid parameters are
Parameter | Type | Description |
---|---|---|
delimiter | string | delimiter of the CSV file, usually ',' or ';' |
encoding | supported encoding | delimiter of the CSV file, usually ',' or ';' |
header | integer | Number of header lines before the data starts. The first will be taken as header names, the remainder will be skipped. |
BIC | string | Bank ID |
defaults | array | list of "field"->"value" mappings to be set for each record before the rules will be applied. |
rules | array | a set of triplets ( "from"=>"column or variable name", "to"=>"column or variable name, "rule"=>, see below) |
The "from" part of the rules works on the conjoint variable space of the CSV input and the already created variables. Therefore, even the use of "temporary" variables is possible. At the end, all non BTX properties will be stored in the data_parsed
field.
Rule | Description |
---|---|
set | will simply copy the value of "from" to "to" |
append[:<x>] | will append the value of "from" to the "to" variable. The part after the colon, if provided, will be used as concat character(s) |
amount | will extract a monetary value from the input filed/variable |
strtotime:<format> | will parse a datetime value with the given format |
{
"delimiter": ";",
"encoding": "CP1252",
"header": 1,
"BIC": "GENODEM1GLS",
"defaults": {},
"rules": [
{
"from": "Kontonummer",
"to": "_ba_id",
"type": "set"
},
{
"from": "Buchungstag",
"to": "booking_date",
"type": "strtotime:d.m.Y"
},
{
"from": "Wertstellung",
"to": "value_date",
"type": "strtotime:d.m.Y"
},
{
"from": "Betrag",
"to": "amount",
"type": "amount"
},
{
"from": "Auftraggeber/Empfänger",
"to": "name",
"type": "set"
},
{
"from": "Währung",
"to": "currency",
"type": "set"
},
{
"from": "VWZ1",
"to": "_party_bank_id",
"type": "regex:/BLZ:(?P<blz>[0-9]+) KTO: *[0-9]+/"
},
{
"from": "VWZ1",
"to": "_party_ba_id",
"type": "regex:/BLZ:[0-9]+ KTO: *(?P<account>[0-9]+)/"
},
{
"from": "VWZ1",
"to": "purpose",
"type": "append: "
},
{
"from": "VWZ2",
"to": "purpose",
"type": "append: "
},
{
"from": "VWZ3",
"to": "purpose",
"type": "append: "
}
]
}