Offer Kaye wrote:
> Hi all,
> I have a text file with columns, where the columns may not be aligned,
> and not all lines may have data in all columns:
> 
> header1     header2     header3    header4
> ------------------------------------------------------------
> l1dat1        l1dat2        l1dat3      l1dat4
> l2dat1                                        l2dat4
> l3veryveryveryverylongdat1 l3dat2
> 
> As you can see, line1 has all data, line2 is missing clomuns 2 and 3,
> line 3 is a mess :)
>

Actually line 2 is the mess, line 3 is simple. Line 2 is ambiguous
unless there is some way to determine that two columns are missing, for
instance is there a maximum column length? How programmatically do you
determine that a column is missing. In other words are columns ever no
longer than X, or a column with X number of characters will never be
followed by more than X space (line 3 is an example of this)? Unless you
can tell us how to avoid the ambiguity there really isn't a way to parse it.

> Any thoughts on parsing such a "table"?
> Please don't offer solutions suggesting to change the way the text
> file is written, I have no control over that...
> 

Well you do have control over it, maybe an unexciting, tedious, manual
control :-)....

> Regards,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to