Perl : not capturing all the data from excel sheet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl : not capturing all the data from excel sheet
# 1  
Old 08-01-2012
Perl : not capturing all the data from excel sheet

Hi folks,

I am working on assignment that captures all the records(2 columns one column contains names and other contain date of birth) from excel sheet stored in a directory and checks for current date and month.
If it matches current date and month then the matched records are printed as "Today is Giridhar's birthday".

PSB code.

Code:
#!perl -w
   use strict; 
    use DateTime;
    use warnings;
    use Spreadsheet::ParseExcel;
    use Time::localtime;
    my $path = "C:\\pro1\\dates.xls";
    my $parser   = Spreadsheet::ParseExcel->new();
    my $workbook = $parser->parse($path);
    my @list;
    my %bdays;
    my %key;
    my $key;
    my $value;
    my @ndate;
     
## for capturing today's date and month for comparision
my $dt = DateTime->now;
# $dt variable is initializes with the current date
my $cday = $dt->day;
my $cyear = $dt->year;
my $cmonth = $dt->month_abbr;

    if ( !defined $workbook ) 
    {
        die $parser->error(), ".\n";
    }
    
    for my $worksheet ( $workbook->worksheets() ) 
    {
        my ( $row_min, $row_max ) = $worksheet->row_range();
        my ( $col_min, $col_max ) = $worksheet->col_range();
        for my $row ( $row_min .. $row_max ) 
        {
            for my $col ( $col_min .. $col_max ) 
            {
                my $cell = $worksheet->get_cell( $row, $col );
                next unless $cell;               
                push(@list,$cell->value());               
                print "\n";
            }
        }
    }

%bdays = @list;
while ( ($key,$value) = each %bdays )
{
    @ndate=split(/-/,$value);  
   if ( $ndate[0] == $cday && $cmonth eq $ndate[1] )
   {
      print "Today is "." $key"."'s"." Birthday","\n";
   }    
}

 #### Now finally we are emptying the hash
  %bdays = ();

Input(excel sheet data)
=================
Giridhar1-Aug-91ram29-Aug-90siva1-Aug-89suman8-Aug-91venkat29-Aug-88sai19-Aug-86rama29-Aug-80siva19-Aug-86Krishna1-Aug-91Mohan1-Aug-90

Output
======
Use of uninitialized value in numeric eq (==) at excel_data_final.pl line 62.
Today is Mohan's Birthday
Today is Giridhar's Birthday
Today is Krishna's Birthday
Press any key to continue . . .


Here, Siva's date is not considered.. Not sure why this happened.
Also I require duplicate records(same names and DoB's) but it is not capturing and also the error message
"Use of uninitialized value in numeric eq (==) at excel_data_final.pl line 62"

Could you please let me know where I made the mistake ?

Moderator's Comments:
Mod Comment Code tags for code, please.
Perl : not capturing all the data from excel sheet-outputjpg

Last edited by Corona688; 08-01-2012 at 07:44 PM..
# 2  
Old 08-01-2012
any help on this will be much appreciated..

Thanks in advance...

Regards,
Giridhar S
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Summing up the data from different excel sheet into one excel sheet

Hi Folks, Can you please advise for any script in unix such that for example , i have 3 different excel sheet at the location /ppt/gfr/exc so the name s of the excel sheet are 1excel.xslx 2excel.xslx 3excel.xslx now in these 3 different excel sheet there is lot of data for example each... (3 Replies)
Discussion started by: punpun66
3 Replies

2. Shell Programming and Scripting

Save log data in excel sheet

Hello, I have the following data format in a log file : a : x1 b : x2 c : x3 d : x4 -------- a : x5 b : x6 c : x7 d : x8 so the same fields ( a ,b ,c,d) repeated many times in the same log file but with different "x" values (x5,x6,x7,x8). I need a script to save this data in an... (6 Replies)
Discussion started by: mm00123
6 Replies

3. UNIX for Dummies Questions & Answers

UNIX data to be updated to ms excel sheet

hi, i wanted to add unix data to be updated to the excel sheet. (3 Replies)
Discussion started by: rupesh.bombale
3 Replies

4. UNIX for Dummies Questions & Answers

Load UNIX data into excel sheet

Hi, i have some data in a temporary file in Unix (the data is taken from the result of an SQL query). Now i want to dump that data into an excel sheet. How to do that. Someone please advise. Thanks Regards, Vinit (3 Replies)
Discussion started by: vinit raj
3 Replies

5. Shell Programming and Scripting

Perl : to get all the hyperlinks from the xlsx sheet(hyperlinks not visible in excel sheet directly)

Hi folks, I have a requirement in perl to print all the hyperlink from the spreadsheet(xlsx). Spreadsheet contains few lines of hyperlink data (pic attached). P.S. Hyperlink is behind the data and not visible in excel sheet directly. Now using perl script I need to copy the hyperlinks in... (3 Replies)
Discussion started by: scriptscript
3 Replies

6. Shell Programming and Scripting

Copy Data from CSV file to Excel Sheet using Perl

Hi All, Firstly I will like to wish A Happy New Year to all. Now my issue is I have one csv file say(data.csv) and one excel file say(result.xls) The result.xls contains two sheet name Sheet1 and Sheet2, Now What I am trying to do is to First I want to delete that data of Sheet2 if present any,... (6 Replies)
Discussion started by: adisky123
6 Replies

7. Programming

converting data from excel sheet to oracle using toad

guys i have data in excel sheet , how do i convert that data to database table (2 Replies)
Discussion started by: Gl@)!aTor
2 Replies

8. Shell Programming and Scripting

Excel sheet modification using perl module

I need to insert new column to already existing file ..can any one help me..?? (6 Replies)
Discussion started by: kavi.mogu
6 Replies

9. Shell Programming and Scripting

Filter data in Excel sheet using Shell Script

Hi, I have an excel sheet which has 100000 records. All these records are having 3 columns each with the last column as "Y" or "N". I would like to filter those records which has the value "Y". Can you please let me know how to proceed with that? Thanks in advance. -Sri ----------... (8 Replies)
Discussion started by: bhanusri83
8 Replies

10. UNIX for Advanced & Expert Users

how to read the data from an excel sheet and use those data as variable in the unix c

I have 3 columns in an excel sheet. c1 c2 c3 EIP_ACCOUNT SMALL_TS_01 select A.* from acc; All the above 3 col shoud be passed a variable in the unix code. 1.How to read an excel file 2.How to pass these data as variable to the unic script (1 Reply)
Discussion started by: Anne Grace
1 Replies
Login or Register to Ask a Question