Example #1
0
/**
* One Line Description
*
* @command csv_to_iif
* @argument path_to_file CSV File
*/
function pestle_cli($argv)
{
    extract($argv);
    $handle = fopen($path_to_file, 'r');
    $process_function = false;
    while ($line = fgetcsv($handle)) {
        if (!$process_function) {
            $process_function = getProcessFunctionFromFirstLine($line);
        }
        call_user_func($process_function, $line);
    }
    output("Hello Sailor");
}
Example #2
0
/**
* One Line Description
*
* @command csv_to_iif
* @argument path_to_file CSV File
*/
function pestle_cli($argv)
{
    extract($argv);
    $handle = fopen($path_to_file, 'r');
    $process_function = false;
    $iifs = [];
    while ($line = fgetcsv($handle)) {
        if (!$process_function) {
            $process_function = getProcessFunctionFromFirstLine($line);
        }
        $iifs[] = call_user_func($process_function, $line);
    }
    $iifs = array_filter($iifs);
    $iifs = array_reverse($iifs);
    \Pulsestorm\Pestle\Library\output('!TRNS	DATE	ACCNT	NAME	CLASS	AMOUNT	MEMO
!SPL	DATE	ACCNT	NAME	AMOUNT	MEMO
!ENDTRNS');
    \Pulsestorm\Pestle\Library\output(implode("\n", $iifs));
}