Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use Excel::Writer::XLSX;
- use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
- use Data::Printer;
- {
- my $output_fn = 'result.xlsx';
- my $input_fn = 'input.txt.gz';
- my $workbook = Excel::Writer::XLSX->new( $output_fn );
- my $worksheet = $workbook->add_worksheet();
- my $zip = IO::Uncompress::Gunzip->new( $input_fn )
- or die "gunzip failed: $GunzipError\n";
- my $col = 0;
- my $row = 0;
- while (!$zip->eof()) {
- my $line = $zip->getline();
- chomp($line);
- next if $line !~ /\S/; # skip empty lines
- my $value = $line;
- $worksheet->write( $row, $col, $value );
- $row++;
- }
- $workbook->close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement