Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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 = 'perlmonks.org.918502.txt'; # or the name of your file my $output_fn = 'perlmonks.org.918502.xls'; # 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2015-07-03 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls