#!/usr/bin/perl5.10 -w
use warnings;
use Spreadsheet::ParseExcel;
use strict;
use IO::Scalar;
use Data::Dumper;
my @etl_val = @ARGV;
print "@etl_val" . "\n" ;
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse("/ms/user/s/sayantag/Demo_MF5.xls");
my $worksheet;
my %order_of_flat_file;
my @data_arr;
my $etl;
my $path;
for $worksheet ( $workbook->worksheets() ) {
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
my $row = $row_min + 2;
while( $row <=$row_max ) {
print "Row before if statement is $row\n";
if ($worksheet->get_cell( $row, 2 )->value ne "END") {
print "Row after if statement is $row\n";
my $etl_cell = $worksheet->get_cell( $row, 2 );
if(defined($etl_cell)) {
$etl = $etl_cell->value;}
my $path_cell = $worksheet->get_cell( $row, 1 );
if(defined($path_cell)) {
$path = $path_cell->value;
$path =~ s/\s$//;
print "PATH: $path" . "\n";}
my $path_cell0 = $worksheet->get_cell( $row, 0 );
if(defined($path_cell0)) {
$path.= $path_cell0->value;
print $path_cell0->value . "\n";
print "PATH: $path" . "\n";
print "ETL: $etl" . "\n";
print "PATH: $path" . "\n";
}
my $data_row;
for my $col ( $col_min+3 .. $col_max ) {
print "ROW : $row" ."\n";
print "COLUMN: $col" . "\n";
my $cell = $worksheet->get_cell( $row, $col );
if (defined($cell) ) {
my $cell_val = $cell->value;
print "Cell value is $cell_val\n";
$data_row .= $cell_val.'|';
print "The first array element is $data_arr[0]\n";
print "Content of '", $path, "' will be:\n", @data_arr, "\n";
} else {$data_row .= '|';
}
}
$data_row =~ s{\|+$}{}; # Remove trailing pipes.
$data_row .= "\n"; # Add line end to end of row.
push @data_arr, $data_row;
$row++;
}
else {# print "The array looks like @data_arr\n";
open("FILEHANDLE", '>', $path) or die "Cannot open the file ", $path, ": $!";
print FILEHANDLE @data_arr ;
close ("FILEHANDLE");
@data_arr = ();
$row = $row+2;
print "Value of row before calling next is $row\n";
next;
}
$order_of_flat_file{$etl} = $path;
}
}
for my $curr_etl_val( @etl_val ){
print $order_of_flat_file{$curr_etl_val}, "\n";
}
foreach my $curr_etl (@etl_val) {
print "\nNow executing workflow $curr_etl\n";
`ksh Command_Line_Etl.ksh "PhoenixFundingAdmin" "NjuX2mfP0k" "PhoenixFunding" $curr_etl "REPO_SVC_PhxR2Qa" "Domain_NY_Qa"`;
}
print "\nAll files are generated after running the workflows. Plot these files as well as the baseline files to a spreadsheet by running the Excel Setup script before Data Compare through Saturn\n\n\n";
|