James, is it possible to ask for a little more help with this?
Nope, you've used up all your free answer tokens. <laughs> Oh, alright, just this once...
Here's the actual data I'm parsing (it's padded with spaces, but dont' worry about them) and delimited by semicolon's.
Ah, the Real-Question-Switcheroo! ;)
DATE;WM REPL SHIPPED;STD REPL SHIPPED;PROMO SHIPPED;ROLLOUT SHIPPED;OTHER SHIPPED;M/I SHIPPED;TOTAL SHIPPED;WM REPL OPEN;STD REPL OPEN;PROMO OPEN;ROLLOUT OPEN;OTHER OPEN;M/I OPEN;TOTAL OPEN;LATE ORDERS;DUMMY ORDERS;DELETED ORDERS;HELD ORDERS ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; 20031002; 5764; 114978; 2288; ; 39; ; 123069; ; ; ; ; ; ; ; ; ; ; 20031003; 55523; 54923; 1105840; ; 157597; 3220; 1377103; ; ; ; ; ; ; ; ; ; ; 20031006; 64457; 152142; 771045; ; 46; 1319; 989009; ; ; ; ; ; ; ; ; ; ; 20031007; 17841; 49993; 190107; ; 28778; 6971; 293690; ; ; ; ; ; ; ; ; ; ; 20031008; 12347; 103861; 1323307; ; ; 9899; 1449414; ; ; ; ; ; ; ; ; ; ; 20031009; 95842; 165819; 977485; ; 3882; 9865; 1252893; ; ; ; ; ; ; ; ; ; ; 20031010; 14384; 131304; 756744; ; 18476; 2152; 923060; ; ; ; ; ; ; ; ; ; ; 20031011; 109672; 132782; 89539; ; 11900; 3834; 347727; ; ; ; ; ; ; ; ; ; ; 20031012; 53112; 118962; 86163; ; ; ; 258237; ; ; ; ; ; ; ; ; ; ; 20031013; 55604; 50646; ; ; ; ; 106250; ; ; ; ; ; ; ; ; ; ; 20031014; 88531; 102857; 529651; ; ; 5782; 726821; 582234; 863117; 9196512; ; 87790; 64738; 10794391; 3740624; 50400; ;
There are 19 columns and what I need is:
The first 8 column in quadrant 1
The next 7 columns in quadrant 2
The Date column (from Q1, 1st column) again, plus the next 7 columns all
in quadrant 3
The last 4 columns in quadrant 4
Okay, are these quadrants on going lists I should keep adding rows too? I'm going to assume yes, for now.
Now, the example above splits the 2D array by 4, placing 4 columns in each quadrant, but I can't figure out the math logic to alter it for my needs above.
Any additional help you can offer would be absolutely awesome and would almost require me to send a keg ;).
Okay, first, just have to ask this question: Are we doing this in the best way we possibly can? What about something like this?
my @data; my @headers = split /;/, scalar <DATAFILE>; while (<DATAFILE>) { chomp; my @fields = split /;/, $_; foreach (@fields) { s/^\s+//; s/\s+$//; } push @data, { map { ($header[$_], $fields[$_]) } 0..$#headers }; }
print Dumper([EMAIL PROTECTED]); # so you can see what it makes...
Okay, enough with my tangent. I'll assume you know what you want and we'll give that a go. Let's change it up a little though, to make my life easier, which is all we really care about ;) :
my %quads = ( quad1 => [ ], quad2 => [ ], quad3 => [ ], quad4 => [ ] ); while (<DATAFILE>) { chomp; my @fields = split /;/, $_; foreach (@fields) { s/^\s+//; s/\s+$//; } push @{ $quads{quad1} }, [ @fields[ 0..7 ] ]; push @{ $quads{quad2} }, [ @fields[ 8..14 ] ]; # I didn't understand the spec perfectly, so you probably need to fix # the following push() where I mostly guessed push @{ $quads{quad3} }, [ @fields[ 0, 8..14 ] ]; push @{ $quads{quad4} }, [ @fields[ 15..18 ] ]; }
print Dumper(\%quads); # just to show what we have here
# or we can keep going to get back to the array you asked for...
my @array_2d = @{ $quads{quad1} }; for (my $i = 0; $i < @array_2d; $i++) { push @{ $array_2d[$i] }, undef, @{ $quads{quad2}[$i] }; } push @array_2d, [ ]; push @array_2d, map { [ @{ $quads{quad3}[$_] }, undef, @{ $quads{quad4}[$_] } ] } 0..$#{ $quads{quad3} };
print Dumper([EMAIL PROTECTED]); # I believe that gets us back to where you wanted to go
Hopefully there's some wisdom buried in all that array mumbo jumbo that will help you along, Good luck.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]