HB_Convert

converting bank.csv files to homebank.csv standard (via definition-file)

20
7
20
3
Python
public

Convert_1.3
Attempt creating a universal Homebank(4.3) csv import converter ©Ton 8-10-2011

[Manual] Program usage

Before you can use this script, you have to create a definition-file (see short manual below)
Format import-csv-file-record homebank = [‘date’,‘paymode’,‘info’,‘payee’,‘description’,‘amount’,‘category’]
Format import-csv-file-record bank = [any number of fields & field-position in record]
Record field seperation-token can be comma or semicolon [,;]

Run in terminal, on command-line type ./Convert_x.x.x.py [import.csv] [output.csv] [import.def]
*
[Leganda] [import.csv] = (“bank”.csv) file exported from bank
[output.csv] = (“homebank”.csv) file to be created
[import.def] = (“bank”.def) definition-file “bank” <> “Homebank”
*
Input-files: [import.csv], [import.def]
Output-files: [output.csv], log.txt (= logging conversion process)

[Manual] Definition-file:
*
Homebank definition file contains multiple lines/records:
*
First line is needed to be able to SKIP Header-line(s) at the top of the [“bank”.csv] file,

  •                                       Line contains 3 fields/columns (left to right):
    

[1] = (H) Homebank field !! field # = [H] >>> do NOT change <<<
[2] = Homebank name !! function >>> do NOT change <<<
[3] = (B) Skipped Bankfile header-lines !! [0…N] (skipped from the top)
*
Rest of lines informs program position of field-data stored in [“bank”.csv] file,

  •                                       Line contains 5 fields/columns (left to right):
    

[1] = (H) Homebank field pos. !! field # = [0…8] >>> do NOT change <<<
[2] = Homebank field name !! as in Homebank >>> do NOT change <<<
[3] = (B) Bankfile field pos. !! field # = [0…N,-1,-M] (M = headerlength)
[4] = Bankfile field name !! as in Bank-file
[5] = Bankfile field details !! line #,pos # (NO semicolons allowed)

Column[3] [0…N] : existing field (possitiv number)

  •                             [-1]    : "not-in-use"        (negative number)
    
  •                             Bank-file contains header with data to be extracted
    
  •                             [-2..-N]: LAST-line of header (negative number) i.e. headerlength
    

NOTE: Multi definitions-lines(rows) per field are possible but cannot contain [-1] !!!
NOTE: header containing data MUST be >= 2 lines !!!

[Without header]
Column[5] must contain information crucial for converting import field-data.

  •                              These 3 fields are Homebank-date, -amount, -paymode.
    

-Date (any order): 4*[Y]ear,2*[M]onth,2*[D]ay -> seperation[-#%&*/] -> [YYYY/MM/DD] [YYYY-MM-DD] [DD%MM%YYYY]
*
-Amount (comes first): Amount without sign needs extra Amount_sign info,

  •                   Amount-format can have grouping-token[,.]
    
  •                                       and decimal-token[.,]
    
  •     limitations:  integers[N*= any number], fraction[None .. 2= max]
    

-Amount_sign (second): [aA-zZ],[aA-zZ] -> order [+,-] -> [D,C] [Debet,Credit] [af,bij] [Neg,Pos]
*
-Paymode (any lenght): N*(Booking-code) , N*(Homebank-code)

  •                   [aA-zZ,0-9],..,[aA-zZ,0-9], [0-10],...,[0-10]     -> [ga,gb,cb,..,tg,kh,db,3,3,4,..,8,9,10]
    
  •                   (any no. of char. per code)
    

NOTE: NO semicolons allowed in Bank-file-field-details !!!

[With header]
Column[5] must contain information crucial for converting import header-data.

  •                              These fields are Homebank-account,-balance
    
  •                              Consists of row/line-number[1-N] and column/line-item-number[0-N].
    
  •          Header:  (line N of header)        , (item N of line)         Example
    
  •                    [2-N]                     , [0-N]                 -> [6,1]
    

=============================================================================================================
Example-definition-file 1 (without header):

H B <“Bank”>
#_______________________________________
0;date ;2 ;Curr.date ;YYYYMMDD
1;paymode ;8 ;Booking-Code ;ga,gb,cb,sb,tb,ba,ck,eb,ei,ma,nb,bg,ac,id,3,3,4,4,5,6,6,7,7,7,7,8,8,8
2;info ;5 ;Offset-account ;
3;payee ;6 ;Payee ;
4;description ;10;Description.1 ;
4;description ;11;Description.2 ;
4;description ;12;Description.3 ;
4;description ;13;Description.4 ;
4;description ;14;Description.5 ;
4;description ;15;Description.6 ;
5;amount ;4 ;Amount ;
5;amount_sign ;3 ;Debet/Credit ;D,C
6;category ;-1; ;
7;*account ;0 ;Account ;
8;*balance ;-1; ;

Example-definition-file 2 (with header 1 line to be skipped):

H B <“Bank”>
#_______________________________________
H;header ;1
0;date ;2 ;Curr.date ;YYYYMMDD
1;paymode ;8 ;Booking-Code ;ga,gb,cb,sb,tb,ba,ck,eb,ei,ma,nb,bg,ac,id,3,3,4,4,5,6,6,7,7,7,7,8,8,8
2;info ;5 ;Offset-account ;
3;payee ;6 ;Payee ;
4;description ;10;Description.1 ;
4;description ;11;Description.2 ;
4;description ;12;Description.3 ;
4;description ;13;Description.4 ;
4;description ;14;Description.5 ;
4;description ;15;Description.6 ;
5;amount ;4 ;Amount ;
5;amount_sign ;3 ;Debet/Credit ;D,C
6;category ;-1; ;
7;*account ;0 ;Account ;
8;*balance ;-1; ;

Example-definition-file 3 (with header containing data):

H B <“Bank”>
#________________________________________
0;date ;2 ;Curr.date ;YYYYMMDD
1;paymode ;8 ;Booking-Code ;ga,gb,cb,sb,tb,ba,ck,eb,ei,ma,nb,bg,ac,id,3,3,4,4,5,6,6,7,7,7,7,8,8,8
2;info ;5 ;Offset-account ;
3;payee ;6 ;Payee ;
4;description ;10;Description.1 ;
4;description ;11;Description.2 ;
4;description ;12;Description.3 ;
4;description ;13;Description.4 ;
4;description ;14;Description.5 ;
4;description ;15;Description.6 ;
5;amount ;4 ;Amount ;
5;amount_sign ;3 ;Debet/Credit ;D,C
6;category ;-1; ;
7;*account ;-7;Account ;2,1
8;*balance ;-7;Balance ;6,1

v0.3.3[beta]