I have a file where the structure is table-like and I need to parse the file after which read and map to my POCO classes. The file looks like as following:
Financial Institution : LOREMIPSOM - 019223
FX Settlement Date : 10.02.2021
Reconciliation File ID : 801-288881-0005543759-00001
Transaction Currency : AZN
Reconciliation Currency : USD
+--------------------------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------+---------------------+
! Settlement Category ! Transaction Amount ! Reconciliation Amnt ! Fee Amount ! Transaction Amount ! Reconciliation Amnt ! Fee Amount ! Count ! Net Value !
! ! Credit ! Credit ! Credit ! Debit ! Debit ! Debit ! Total ! !
+--------------------------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------+---------------------+
! MC Acq Fin Detail ATM Out 5.00 3.57 49.75 0.00 0.00 0.00 31 3.32 !
! MC Acq Fin Detail Retail Out 5.40 262.01 0.00 0.00 0.00 -3.96 10 258.05 !
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Totals : 10.40 265.58 49.75 0.00 0.00 -3.96 41 261.37
Financial Institution : LOREMIPSOM - 019223
FX Settlement Date : 10.02.2021
Reconciliation File ID : 801-288881-0005543759-00002
Transaction Currency : EUR
Reconciliation Currency : USD
+--------------------------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------+---------------------+
! Settlement Category ! Transaction Amount ! Reconciliation Amnt ! Fee Amount ! Transaction Amount ! Reconciliation Amnt ! Fee Amount ! Count ! Net Value !
! ! Credit ! Credit ! Credit ! Debit ! Debit ! Debit ! Total ! !
+--------------------------------------+--------------------+---------------------+---------------------+---------------------+---------------------+---------------------+---------+---------------------+
! Fee Collection Inc 0.00 0.00 0.00 0.00 0.00 0.00 0 0.00 !
! Fee Collection Inc 0.00 0.00 0.00 8.00 0.00 0.00 0 0.00 !
! Fee Collection Inc 0.00 0.00 0.00 0.00 0.00 0.00 0 0.00 !
! Fee Collection Inc 0.00 0.00 0.00 -1.00 0.00 0.00 0 0.00 !
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Totals : 0.00 0.00 0.00 7.00 0.00 0.00 0 0.00
I was thinking parsing it manually, I thought maybe there is a better way.. and about the parsing data so I need every data that is reasonable to parse, so I need to parse the file and get every data except for +- symbols. Also the file structure doesn't change so the columns are always there (fixed). The file as you can see is a bank related file (transations). So There is this "Financial Institution" for example that I map and other data. "Settlement Category" of this "Financial Institution " is "MC Acq Fin Detail ATM Out" for example. What would be the best way to parse the file?