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

Re^3: Plot a chart

by poj (Prior)
on Jul 24, 2014 at 09:44 UTC ( #1094880=note: print w/replies, xml ) Need Help??


in reply to Re^2: Plot a chart
in thread Plot a chart

Try reading your csv files with Text:CSV_XS, adding use strict; use warnings and some print diagnostics.
#!perl use strict; use warnings; use Spreadsheet::WriteExcel; use Text::CSV_XS; my $csv = Text::CSV_XS->new({ binary => 1, sep_char => ',', eol => "\n"}); my $xlsfile = 'c:/temp/xyz_stat1.xls'; my $workbook = Spreadsheet::WriteExcel->new($xlsfile) or die $!; my $num_files = $ARGV[0] || 0; for my $k (1..$num_files){ my $csvfile = $ARGV[$k]; print "Opening $csvfile .. "; open my $fh, '<', $csvfile or die "Cannot open $csvfile : $!"; my $sheet = $workbook->add_worksheet('sim_'.$k); my $ar = $csv->getline_all($fh); $sheet->write_col(0,0,$ar); close $fh; print scalar (@$ar). " lines read into sheet sim_$k\n"; } $workbook->close; print "$xlsfile created\n";
poj

Replies are listed 'Best First'.
Re^4: Plot a chart
by wizsc (Initiate) on Jul 24, 2014 at 23:37 UTC

    The issue is that the numbers are being written as strings or characters, second column onward. So it's not able to print it. Either of these two fixes will work.

    1. Account for white spaces:

    my @frame_stats = split(/,\s+/,$line);

    2. Use "write_number":

    $worksheet[$k]->write_number($frm_num, $col, $el);

    Thanks a bunch for all your help!!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1094880]
help
Chatterbox?
LanX starts googling the punch line ...
[choroba]: suddenly, a weird noise can be heard, and the conductor stops them
[choroba]: (sorry, was interrupted by a call)
[choroba]: What was that? asks he
[choroba]: and the triangle player says, "That was me. It's written here in the score"
[choroba]: and shows a bar with a note "ohne Triangel"
[choroba]: where "ohne" means "will bend" in Czech

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-03-27 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.