Export csv to bz2

A Sub for exporting data into bzipped csv

Qlik

I argue for bzip2 that is data.table::fread() (also for Py) friendly and gives better compression than gzip.

SUB ExportCsv(t, fn)
    EXIT SUB when IsNull(t);
    TRACE [ExportCsv] CALLED for [$(t)];

    EXIT SUB when IsNull(fn) and IsNull(vExportPath);
    fn = If(not IsNull(fn), '$(fn)', '$(vExportPath)\$(t).csv');
    TRACE [ExportCsv] will dump to [$(fn)];
    STORE [$(t)] into [$(fn)] (txt);

    // bzip2 is data.table::fread() friendly (and gives better compression than gz)
    EXECUTE C:\opt\rtools40\usr\bin\bzip2.exe -fz1 "$(fn)";

    TRACE [ExportCsv] DONE;
END SUB


// // Usage example:
// LET vExportPath='C:\tmp';
// tx:
// LOAD RowNo() AutoGenerate(1e3);
// CALL ExportCsv('tx');