rickyboy has asked for the wisdom of the Perl Monks concerning the following question:
Dear great ones, I have turned to the almighty Perl to make a spread sheet. It's made life incredibly easy for me up until now. I need to add data from files into columns. The problem is, I don't know how many columns there will be or how many files as the data I'm using for the files is variable. For example,
my $intStartRow = 0; my $altRow = $intStartRow; my $intStartCol = 2; my $altCol = $intStartCol; open (FRUITS, '/home/fruit_types.txt') or die ("Problem opening file: +$!"); # Fruit Header Insertion my $row = 1; while (<FRUIT>) { chomp; # Split on single tab my @Fld = split ('\t', $_); my $col = 3; foreach my $token (@Fld) { $worksheet->write($altRow, $altCol++, $token, $format); $col++; } $row++; }
So I have a file called fruit_types which contains the strings (apple, banana, orange, etc). The perl script will automatically put those strings into their own columns at the head of the spread sheet. The types of fruit will be variable so I will not know how many strings will be in the file, hence why it is added using the script above. I then have a directory with a separate file for each fruit i.e (apple.txt, banana.txt, orange.txt, etc). Inside each file contains spread sheet data (1,2,5, etc) to represent the amounts of each fruit I have. I now want to tie that data into the relevant column (apple, banana, orange, etc). The spread sheet would look like this...
Can someone enlighten me how I would go about doing this? Thanks, Richard.apple banana orange 1 2 5 2 3 8 3 1 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using variable files to add data into excel spreadsheet
by Laurent_R (Canon) on May 21, 2014 at 17:03 UTC | |
|
Re: Using variable files to add data into excel spreadsheet
by RonW (Parson) on May 21, 2014 at 22:12 UTC | |
by NetWallah (Canon) on May 22, 2014 at 05:01 UTC | |
by Anonymous Monk on May 22, 2014 at 10:26 UTC | |
by poj (Abbot) on May 22, 2014 at 11:28 UTC | |
by rickyboy (Novice) on May 23, 2014 at 13:36 UTC | |
| |
by RonW (Parson) on May 22, 2014 at 18:00 UTC | |
by rickyboy (Novice) on May 23, 2014 at 13:55 UTC |