marjun
marjun

Reputation: 726

How to read excel sheet using perl script with simple check condition

Im new bee to perl trying to read excel sheet with simple condition..

problem is reading all records and checking whether b columns has "Always null" string if yes then display output from Column "C"

Example : For Always Null condtion

Expected output : a,b,c,f,g

enter image description here

Upvotes: 0

Views: 232

Answers (1)

edem
edem

Reputation: 3272

#!/usr/bin/perl 

use strict;
use warnings;
use v5.14;

use Spreadsheet::ParseExcel;
use Data::Dumper;

my $ws = Spreadsheet::ParseExcel
                ->new()
                ->parse('yourfile.xls')
                ->worksheet(0);

my ($i, $r_max) = $ws->row_range;

my ($cell_B, $cell_C);

while ($i <= $r_max) {
    $cell_B = $ws->get_cell($i,1);
    $cell_C = $ws->get_cell($i,2);

    say $cell_C->value 
        if $cell_B 
            and $cell_C 
            and $cell_B->value eq 'Always null';
} continue { $i++ }

Upvotes: 2

Related Questions