in reply to reading columns from a flat file
You could write a short perl script (or even a one-liner) that would read the inverted input file and re-invert it to stdout. You can then use this to read and convert the file and read it's output directly using a piped open (See perlopentut)
The following example processes a simple whitespace delimited file and inverts it. You'll need to adapt flip.pl to your formats. Also, it assumes that every line will have the same number of columns as the first.
Note: The one-liner manually wrapped and uses win32 quoting.P:\test>type test.dat 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 P:\test>type flip.pl #! perl -slw use strict; my @cols; push @cols, [ split ] while $_ = <>; for my $n ( 0 .. $#{ $cols[ 0 ] } ) { print join ' ', map{ $_->[ $n ] } @cols; } P:\test>perl -le " open F, qq[ flip test.dat |]; print join '|', split while $_ = <F>; " 1|1|1|1|1|1|1|1 2|2|2|2|2|2|2|2 3|3|3|3|3|3|3|3 4|4|4|4|4|4|4|4 5|5|5|5|5|5|5|5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: reading columns from a flat file
by nosbod (Scribe) on Mar 19, 2004 at 11:23 UTC | |
by BrowserUk (Patriarch) on Mar 19, 2004 at 11:54 UTC | |
by nosbod (Scribe) on Mar 19, 2004 at 12:11 UTC | |
by davido (Cardinal) on Mar 20, 2004 at 05:23 UTC |