in reply to Re^4: Parsing .txt into arrays
in thread Parsing .txt into arrays
Right now it appears that you are expecting me to write your code for you - without demonstrating much effort on your part.
I do have clients that pay me for solving their problems. Quite frankly these folks will get much higher priority than you. However I and others here are willing to help you learn. BUT, that means that you need to show some coding effort.
Your points 4,5,6 and 7 tell me that you didn't run much less understand the code which I modified for you.
1) Transposing a table, converting rows to columns is not that difficult if you think logically about it. I want to see a serious attempt by you. Use the 2-d table that my code generates.
2) Setting the current field to what was before in the case that it is "blank" (whether row-wise or column-wise) is also something that you should be able to make an attempt at.
The construction of a state machine to parse your various tables was beyond either of these tasks and I felt that it was necessary to get you "unstuck".
Solving this problem will help you. Write code that generates @transposed using @array as input. I know its hard, but give it a go...
#!/usr/bin/perl use strict; use warnings; my @array = ( ['a', '1', 'L'], ['b', '2', 'M'], ['c', '3', 'N'], ['d', '4', 'O'],); my @transposed = ( ['a', 'b', 'c', 'd'], ['1', '2', '3', '4'], ['L', 'M', 'N', 'O'],); foreach my $row_ref (@array) { print "@$row_ref\n"; } # Prints: #a 1 L #b 2 M #c 3 N #d 4 O foreach my $row_ref (@transposed) { print "@$row_ref\n"; } # Prints: #a b c d #1 2 3 4 #L M N O
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Parsing .txt into arrays
by Fshah (Initiate) on Jun 07, 2017 at 06:30 UTC | |
by Marshall (Canon) on Jun 07, 2017 at 07:35 UTC | |
by Fshah (Initiate) on Jun 12, 2017 at 04:37 UTC | |
by Marshall (Canon) on Jun 13, 2017 at 01:52 UTC | |
by Fshah (Initiate) on Jun 14, 2017 at 10:06 UTC | |
|