Convert file to excel

D

Deepu

Hi All,

I am trying to create a table with some data and store it in a file and
then it should be used in excel to create 3D bar chart. Can some one
provide me with some ideas on how it can be done.

Thanks for your time.

Code:

I have file which contains so many other details and have a line in the

file which start with:

#RESULT: 30 => YES: 10 NO: 10 UNKNOWN: 10

I have several files with each file have a line with RESULT.

##### Code starts here ####

#!/usr/bin/perl

@dirList= qw(FILE1 FILE2 FILE3 FILE4 FILE5);

foreach $dir (@dirList) {
open (PH, "$dir") || die "Can not open:$dir";

while (<PH>) {
if (/#RESULT: (\d+) => YES: (\d+) NO: (\d+) UNKNOWN: (\d+)/) {
push (@yesArray, $2);
push (@noArray, $3);
push (@unknownArray, $4);
}
}

close (PH);

}

## -- help from Mumia W ---
my $fmt = "-%10s %5s %5s %5s\n";
printf ($fmt, '', qw(YES NO UNKNOWN));

foreach $dir(@dirList) {
printf $fmt, $dir, $yesArray[$_], $noArray[$_], $unknownArray[$_];
$_++;
}

The output generated is:

YES NO UNKNOWN
FILE1 10 8 14
FILE2 6 7 20
FILE3 18 10 10
FILE4 20 12 10
FILE5 10 10 10

Now i am trying to save this table in a file so that it can be read by
Excel and create bar chart. Is there any way possible to automate this
flow.

Thanks for the help.
 
B

Brian McCauley

Deepu said:
The output generated is:

YES NO UNKNOWN
FILE1 10 8 14
FILE2 6 7 20
FILE3 18 10 10
FILE4 20 12 10
FILE5 10 10 10

Now i am trying to save this table in a file so that it can be read by
Excel and create bar chart.

Excel can read CSV files.

There's also a module on CPAN to write Excel files but it can't do
fancy stuff like include macros.
Is there any way possible to automate this flow.

You can drive Excel via OLE. (f you know the OLE commands you want
then Win32::OLE will let you do them).

Alternatively you could write an Excel macro that runs your Perl script.
 
T

Tad McClellan

Deepu said:
#!/usr/bin/perl

use warnings;
use strict;

@dirList= qw(FILE1 FILE2 FILE3 FILE4 FILE5);
foreach $dir (@dirList) {


Calling something that is not a directory "dir" is likely to lead
to easily avoided confusion.

open (PH, "$dir") || die "Can not open:$dir";


perldoc -q vars

What's wrong with always quoting "$vars"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top