Outputing each true line to hash

3 views
Skip to first unread message

Fu

unread,
Oct 10, 2007, 9:22:08 AM10/10/07
to OpenWFEru users
Is there a way to output every true line? I have tried the below
without success. It will evaluate each line but only output the last
true line to the hash.

through
in:f1,in:f1,in:f2,in:f3,out:o1,out:e1,out:e2

<100,>=95,<=2.0,<=5,"Output1",,
<100,>=95,,,"Output2,,
<100,>=95,>2.0,,"Expection1",,
<100,>=95,,>2.0,,,"Expection2"
<100,>=95,,>2.0,"Invalid",,

So using f1=97 and f2=5 the output hash should have:

Output2
Expection1

Right now it would just output "Invalid".

John Mettraux

unread,
Oct 10, 2007, 9:46:48 AM10/10/07
to openwfe...@googlegroups.com
On 10/10/07, Fu <fu.z...@gmail.com> wrote:
>
> Is there a way to output every true line? I have tried the below
> without success. It will evaluate each line but only output the last
> true line to the hash.
>
> through
> in:f1,in:f1,in:f2,in:f3,out:o1,out:e1,out:e2
>
> <100,>=95,<=2.0,<=5,"Output1",,
> <100,>=95,,,"Output2,,
> <100,>=95,>2.0,,"Expection1",,
> <100,>=95,,>2.0,,,"Expection2"
> <100,>=95,,>2.0,"Invalid",,

Hi Fu,

I've double checked the test cases for "through", they work fine.

You should write
"through,,,,,,"
instead of
"through"

I could reproduce your error. I'll probably make sure that this
problem doesn't appear in later releases of OpenWFEru.


Best regards,

--
John Mettraux -///- http://jmettraux.openwfe.org

John Mettraux

unread,
Oct 10, 2007, 9:05:31 PM10/10/07
to openwfe...@googlegroups.com
On 10/10/07, John Mettraux <jmet...@openwfe.org> wrote:
> On 10/10/07, Fu <fu.z...@gmail.com> wrote:
> >
> > Is there a way to output every true line? I have tried the below
> > without success. It will evaluate each line but only output the last
> > true line to the hash.
> >
> > through
> > in:f1,in:f1,in:f2,in:f3,out:o1,out:e1,out:e2
> >
> > <100,>=95,<=2.0,<=5,"Output1",,
> > <100,>=95,,,"Output2,,
> > <100,>=95,>2.0,,"Expection1",,
> > <100,>=95,,>2.0,,,"Expection2"
> > <100,>=95,,>2.0,"Invalid",,

Hi Fu,

I've reread your post. Through works well, but it seems you want the
matched values to accumulate somehow.

The CsvTable doesn't "output" to the STDOUT, it simply sets "out:"
fields. I have added your test case to
http://openwferu.rubyforge.org/svn/trunk/openwfe-ruby/test/extras/csv_test.rb
(see test #11)

It works as expected, it sets "o1" to "Output2", then it sets
(overrides) it to "Expection1" (exception ?).

Are you looking for some accumulative behaviour or did you mean to set
e1 to "Expection1" ?


Actually "accumulate" as an extension of "through" is quite a nice idea.

Fu

unread,
Oct 11, 2007, 12:52:24 AM10/11/07
to OpenWFEru users
John,

Yes I am looking for accumulate behavior.

I missed type the csv table. Sorry for the confusion. It should be
the following:

100,>=95,<=2,<=2,"Output1",,
<100,>=95,,,"Output2,,
<100,>=95,>2.0,,,"Expection1",
<100,>=95,,>2.0,,,"Expection2"
,,,,,,"Invalid"

Using the "through,,,,,," worked for what I needed to get done.

I thought I could acumulate true values into one variable but after
reading you last post realized that I could do it in many variables
and add them up.

The problem I needed to solve was to be able to test for all
possiblities within the scope of variables. So if the first line of
the csv table "<100,>=95,<=2.0,<=5,"Output1",, " was not valid line
two "<100,>=95,,,"Output2,," could still be valid but with additional
possiblities noted by "Expection1" and "Expection2". (I meant
"Execption" but I missed type it.)

Although the csv table is rather large, since I essentially test every
possibility by row and column, it allows me to cover all possiblities
and is still more compact then do any othe types of logic. I am not
sure if there is a better way to do it with OpenWFEru.

Thanks for all the comments and work you have done.

Fu


On Oct 10, 6:05 pm, "John Mettraux" <jmettr...@openwfe.org> wrote:
> On 10/10/07, John Mettraux <jmettr...@openwfe.org> wrote:


>
> > On 10/10/07, Fu <fu.zh...@gmail.com> wrote:
>
> > > Is there a way to output every true line? I have tried the below
> > > without success. It will evaluate each line but only output the last
> > > true line to the hash.
>
> > > through
> > > in:f1,in:f1,in:f2,in:f3,out:o1,out:e1,out:e2
>
> > > <100,>=95,<=2.0,<=5,"Output1",,
> > > <100,>=95,,,"Output2,,
> > > <100,>=95,>2.0,,"Expection1",,
> > > <100,>=95,,>2.0,,,"Expection2"
> > > <100,>=95,,>2.0,"Invalid",,
>
> Hi Fu,
>
> I've reread your post. Through works well, but it seems you want the
> matched values to accumulate somehow.
>
> The CsvTable doesn't "output" to the STDOUT, it simply sets "out:"

> fields. I have added your test case tohttp://openwferu.rubyforge.org/svn/trunk/openwfe-ruby/test/extras/csv...

John Mettraux

unread,
Oct 11, 2007, 1:05:55 AM10/11/07
to openwfe...@googlegroups.com
Hi Fu,

On 10/11/07, Fu <fu.z...@gmail.com> wrote:
>
> I thought I could acumulate true values into one variable but after
> reading you last post realized that I could do it in many variables
> and add them up.
>
> The problem I needed to solve was to be able to test for all
> possiblities within the scope of variables. So if the first line of
> the csv table "<100,>=95,<=2.0,<=5,"Output1",, " was not valid line
> two "<100,>=95,,,"Output2,," could still be valid but with additional
> possiblities noted by "Expection1" and "Expection2". (I meant
> "Execption" but I missed type it.)
>
> Although the csv table is rather large, since I essentially test every
> possibility by row and column, it allows me to cover all possiblities
> and is still more compact then do any othe types of logic. I am not
> sure if there is a better way to do it with OpenWFEru.

It seems you are using it as should be.

> Thanks for all the comments and work you have done.

You're welcome, thanks for the ideas. I'm glad OpenWFEru can help you
in your work.


I liked the "accumulate" idea, so I implemented it, I also implemented
the Ruby ranges, though they were not really required.

You can benefit from them by checking out the code :

svn checkout http://openwferu.rubyforge.org/svn/trunk/openwfe-ruby

It's not yet properly documented, but the last tests at
http://openwferu.rubyforge.org/svn/trunk/openwfe-ruby/test/extras/csv_test.rb
show how it works.

You can use the "accumulate" option instead of the "through" one and
an array of values will build up, instead of the default 'override'
behaviour.


Hope this will be useful, best regards,

Reply all
Reply to author
Forward
0 new messages