Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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); }

Comment on Re^2: output to excel
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://918516]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2015-11-26 16:06 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (701 votes), past polls