PHP code example of kokonut-ch / laravel-swiss-bank-csv-parser

1. Go to this page and download the library: Download kokonut-ch/laravel-swiss-bank-csv-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kokonut-ch / laravel-swiss-bank-csv-parser example snippets


use Kokonut\SwissBankCsvParser\Facades\SwissBankCsvParser;

$file = SwissBankCsvParser::parse($request->file('statement')->get());
// or SwissBankCsvParser::parseFile('/path/to/statement.csv')

$file->bank->name;          // 'PostFinance'
$file->profile;             // 'postfinance.efinance'
$file->account->iban;       // 'CH9300762011623852957'
$file->account->currency;   // 'CHF'
$file->period->from;        // DateTimeImmutable|null, the period the file announces

foreach ($file as $row) {
    $row->date;        // DateTimeImmutable
    $row->valueDate;   // DateTimeImmutable|null
    $row->label;       // 'Paiement fournisseur'
    $row->amount;      // '-150.50', signed decimal string, negative means money out
    $row->currency;    // 'CHF'
    $row->balance;     // '8759.45' or null
    $row->reference;   // whatever the bank printed, if anything
    $row->extras;      // ['Catégorie' => 'Achats'], recognised but outside the core model
    $row->raw;         // the original cells, so nothing is ever lost
}

$file = \SwissBankCsvParser::parse($contents);

$report = SwissBankCsvParser::detect($csvContents);

$report->best()->bank->name;   // 'PostFinance'
$report->best()->score;        // 0.90
$report->best()->reasons;      // ['distinctive heading "Texte de notification"', …]

if (! $report->isConfident()) {
    // Several profiles could read this, or none stands out.
    // A good moment to ask whoever uploaded it.
}

$row->extras['Status'];  // 'Booked'