Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

Parsing Excel Data

I have been asking this question but due to the vague nature of the question I am not getting what exactly I am looking for.
I have come up with a mechanism how I want it and I will detail it down now. But to understand it you should open both links of the excel sheets.

http://socr.uwindsor.ca/~choudh8/output.xls
http://socr.uwindsor.ca/~choudh8/dummy.xls

As you see in the output.xls some data is sitting there. Please notice for every IPD file path there is a data. It Contents, Number of Records and Size.
Notice in the other file dummy.xls Contents are already there. All I need is to transfer these records and file sizes for every file. With the file name on top and its data underneath and then it moves towards right
Here is the Mechanism
IF{ @ column A of output file the script sees a path to IPD file
GO TO {dummy.xls on column B first row and copy/paste the IPD file name and in the next row copy/paste (Number of Records and Size)
GO back to output.xls
Match the contents underneath this IPD file
IF {the contents match place its data in front of the matched contents}
ELSE{try to match the next content (If it macths place the data otherwise move forward}
I guess    FOR LOOP    will be used
Do this process until the script hits the BLANK row (as seen in the output.xls file)
Go back to the first IF statement and do the exactly same process.
THE ONLY DIFFERENCE WILL BE THIS TIME THE IPD FILE NAME SHOULD BE COPY/PASTED TO THE NEXT COLUMN AND SO ON UNTIL THERE ARE IS NO DATA LEFT IN THE OUTPUT.XLS
To further understand the last point suppose the first IPD data copy/pasted in from Column B to C then next data should be from Column E to F and so on.
0
Musaab1
Asked:
Musaab1
  • 5
  • 5
1 Solution
 
ozoCommented:
#is this what you mean?
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel::Simple;
my $oExcel = new Spreadsheet::ParseExcel;
my $contents=$oExcel->Parse('dummy.xls');
@C=map {[map{$_&&$_->{Val}}@$_]} @{$contents->{Worksheet}[0]{Cells}};
@row{map{$_->[0]=~/(\S.*\S)/}@C}=0..$#C;
my $log=$oExcel->Parse('output.xls');
for( @{$log->{Worksheet}[0]{Cells}} ){
    push @{$C[0]},$arg = $_->[0]{Val},undef if @{$_}==1;
    my($c,$n,$s)=map{$_&&$_->{Val}}@$_;
    s/^\s+//,s/\s+$// for $c;
    @{$C[$row{$c}]}[$#{$C[0]}-1,$#{$C[0]}] = $n,$s if $row{$c};
}
my $ss = Spreadsheet::WriteExcel::Simple->new;

$ss->write_row($_) for @C;
$ss->save("new.xls");
0
 
Musaab1Author Commented:
I am trying to test this code and it says that
Can't locate spreadsheet/writeexcel/simple.pm in @INC contains: c:/perl/lib c:/perl/site/lib .) at test1.pl line 3
BEGIN failed--compilation aborted at test1.pl line 3

Thanks a lot OZO for helping
0
 
Musaab1Author Commented:
Hello OZO
I placed the simple.pm in the spreadsheet/writeexcel loaction but now I see this

Can't locate object method "new" via package "spreadsheet::writeexcel::simple.pm" (
perhaps you forgot to load "spreadsheet::writeexcel::simple.pm"? at test1.pl line 15
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Musaab1Author Commented:
Hello Ozo I totally agree wiht your code as you are the master in perl but i dont know what should I do in this situation when I am getting this error even though everythign seems fine.

Thanks
0
 
ozoCommented:
did you install Spreadsheet::WriteExcel::Simple?
try the command
cpan Spreadsheet::WriteExcel::Simple
0
 
Musaab1Author Commented:
its working now OZo but now I am getting this
It runs and then stops with this comment
Modification of read-only value attempted at  test.pl line 5
0
 
ozoCommented:
Is dummy.xls the same as the one you posted?
What do you get from

use Spreadsheet::ParseExcel;
my $oExcel = new Spreadsheet::ParseExcel;
my $contents=$oExcel->Parse('dummy.xls');
use Data::Dumper;
print Dumper map{ref} @{$contents->{Worksheet}[0]{Cells}};
print Dumper map {[map{ref}@$_]} @{$contents->{Worksheet}[0]{Cells}};
0
 
ozoCommented:
and what do you get from
print Dumper map {[map{$_&& join', ',keys %$_}@$_]} @{$contents->{Worksheet}[0]{Cells}};
0
 
Musaab1Author Commented:
Thanks for ur help Ozo I am closing this question too I wrote a macro to do this job
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now