Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

How to fill a template values from a excel using perl?

by ksikder (Initiate)
on May 02, 2019 at 17:31 UTC ( #1233295=perlquestion: print w/replies, xml ) Need Help??

ksikder has asked for the wisdom of the Perl Monks concerning the following question:

I have an excel with 10 rows and 15 columns. First row is the name of the parameters and rest are their values respectively. Each row represents different set of parameter values.

I want the perl script to create a script based on a template which will take all the parameter values and put them in an array.
blue red green orange 5 4 6 6 2 3 4 9 1 2 4 5
The script will create a file like this:
arg (row 1 elements) "blue indexes are" @blue=[5 2 1]; "red indexes are" @blue=[4 3 2]; "green indexes are" @blue=[6 4 4]; "orange indexes are" @blue=[6 9 5]; }

Replies are listed 'Best First'.
Re: How to fill a template values from a excel using perl?
by thanos1983 (Parson) on May 02, 2019 at 18:18 UTC

    Hello ksikder,

    Welcome to the Monastery.

    You can start by reading How to read an Excel file in Perl. As soon as you have a sample of running code and you are stuck somewhere you can raise another question and we can take it from there :).

    Start coding and we can help you, but please do not ask us to do it for you :).

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re: How to fill a template values from a excel using perl?
by Marshall (Canon) on May 03, 2019 at 10:45 UTC
    You have some work to do.
    However, if you wind up with an array as you show, code like this might be useful to you..
    Other code can be used to translate a row,column to column,row.
    Make some kind of attempt at your code and post it here and you will get a lot of help.
    Your code does not have to be "pretty" or even completely work. Trying is important.
    #!/usr/bin/perl use strict; use warnings; my @array = qw(5 4 6 6 2 3 4 9 1 2 4 5); my (@blue, @red, @green, @orange); while (@array) { my ($blue, $red, $green, $orange) = splice(@array,0,4); push @blue, $blue; push @red, $red; push @green, $green; push @orange,$orange; } print "Blue = @blue\n"; print "Red = @red\n"; print "Green= @green\n"; print "Orange = @orange\n"; __END__ Blue = 5 2 1 Red = 4 3 2 Green= 6 4 4 Orange = 6 9 5

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1233295]
Approved by LanX
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-05-14 17:53 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (150 votes). Check out past polls.