Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: output to excel

by cjb (Friar)
on Aug 04, 2011 at 13:00 UTC ( #918516=note: print w/replies, xml ) Need Help??

in reply to Re: output to excel
in thread output to excel

It's lunch time, I'm bored. Something like this should work .
#!perl.exe use Modern::Perl; #or use strict;use warnings; use Spreadsheet::WriteExcel; my $input_fn = ''; # or the name of your file my $output_fn = ''; # or the name of the xls f +ile you want to produce #open the input for reading open my $input_fh, '<', $input_fn or die "Unable to open $input_fn: $1 +\n"; #open xls file for output my $workbook = Spreadsheet::WriteExcel->new($output_fn); die "Problems creating Excel file: $!\n" unless defined $workbook; #create a worksheet with the name of the input file my $worksheet = $workbook->add_worksheet($input_fn); #split the line, and write to the matching row in the spreadsheet while (my $line = <$input_fh>) { $line =~ /(\d+).{5}(\d+.\d+)\s(\d+.\d+)\s(\d+.\d+)/; my @columns = ($2, $3, $4); $worksheet->write_row($1,0,\@columns); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://918516]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2018-01-16 10:16 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (177 votes). Check out past polls.