The bzip2.unzip function allows decompressing a bytes string compressed in BZIP2format.

1 bzip2.unzip

Decompress the data string in BZIP2 format indicated as parameter.

<bzip2.unzip>
    <object2Stream /> !
</bzip2.unzip>
Example

Decompress the file [sample_bzip2.bz2] and store the content of the file [result_bzip2.txt].

Copy
<xsql-script>
    <body>
        <file.out.open id='out1' append='true'>
            <file name='result_bzip2.txt' type='absolute' />
        </file.out.open>

        <file.out.write id='out1' append='true'>
            <bzip2.unzip>
                <file name='C:/tmp/sample_bzip2.bz2' type='absolute'  />
            </bzip2.unzip>
        </file.out.write>

        <file.out.flush id='out1' />
        <file.out.close id='out1' />
    </body>
</xsql-script>
Example

Read a compressed file line by line without the need to create a temporary file.

Copy
<xsql-script>
    <body>
        <set name='p_in'>
            <string.lineReader><bzip2.unzip><file type='absolute' name='C:\temp\sample3.bz2' /></bzip2.unzip></string.lineReader>
        </set>
        
        <while>
            <expr>
                <isnotnull>
                    <set name='p_line'>
                        <string.lineReader.readLine><p_in/></string.lineReader.readLine>
                    </set>
                </isnotnull>
            </expr>
        <do>
            <println><p_line/></println>
        </do>
    </while>    
     </body>
</xsql-script>