[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Txr-users] matching blank lines
From: |
Daniel Lyons |
Subject: |
[Txr-users] matching blank lines |
Date: |
Tue, 23 Feb 2010 19:51:39 -0700 |
User-agent: |
Sup/0.10.2 |
Hi,
Thanks for txr! This is an immensely helpful program and I'm looking forward
to using it in all sorts of situations where awk/sed/etc. are
unpleasant. Unfortunately, I am running into a problem.
I'm processing a fixed-width file which defines products and their prices. The
first line of a group of lines contains all of the values except the customer
code. All of the subsequent lines omit all of the values except the customer
code and the final price. So it looks something like this:
ProductID Description .... Retail $ Cust.Code Price
foo This is the foo product... 47.50 47.50
A 47.50
B 43.20
C 38.30
bar Yet another product... ....
.
.
.
I'm having trouble figuring out just how to parse this. My initial inclination
was to attack it like this (these are the wrong column lengths because I don't
want to attach the file; not sure if it's proprietary or not):
@/.*/@# discard the header
@(collect)
@{product_id address@hidden address@hidden 6}@/ */@{price 6}
@(freeform "\n\n")
@(coll)@/ +/@{level /[A-Z]+/}@/ +/@{price /[0-9,.]+/}@/ *\n/@(end)
@(end)
For some reason, this causes the query to fetch the whole rest of the file for
the @level and @price variables and it never advances the overall collect. If
I use different separators for @(freeform) I either seem to get the same
behavior or the query fails.
I suspect there's an easier way to approach this but I'm not sure what it is.
Thanks,
--
Daniel Lyons
- [Txr-users] matching blank lines,
Daniel Lyons <=