Raul, Devon, thank you for your quick responses.  

Raul, I currently use regexes to do this job in a SQL server SSIS
package I wrote, but I figured it would be much simpler in J to cut,
index and take the attributes of interest.

The attribute names do not follow a regular pattern as they do in the
dummy data (i.e. att1, att2 etc.), they are more like (numresults,
TINCATL6, cidresultpos, WT.vt_f_a, tnet_test_panel etc.) and there can
be many (30-50) stuffed into a single line.  I don't want to manage the
regex definitions like I need to do in SSIS.

Anyway, the solutions you and Devon provided look like what I need.

I will let you know how it goes.

Devon, I owe you a few beers at NYCJUG tonight. 
Raul, I will buy you a beer if you ever have the chance to attend the
NYCJUG meeting.

Thanks again.

Ken    


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Raul Miller
Sent: Tuesday, November 11, 2008 4:18 PM
To: Programming forum
Subject: Re: [Jprogramming] Extracting values from log strings

On Tue, Nov 11, 2008 at 3:38 PM, Lettow, Kenneth <[EMAIL PROTECTED]>
wrote:
... lots of stuff...

First off, I think you should have explicitly included
   require'strings'
to get the definition of cut that you use.

Second off, the idiom I use to convert numbers to boxed words is ":each
This works because the monad > on an integer is the identity function,
but with a rank of 0.

For example:
   ":each i.8

Anyways, long story short, your genattdat was too complicated for
me to understand, so I rewrote it (and made a subtle change that
hopefully does not matter):

genattdat=: 3 : 0  NB. Verb to generate dummy data
 MAXATTS=. 8      NB. maximum demo attributes per line
 MAXVAL=. 5000    NB. max dummy value
 attrlist=: 'att'&,@":each i.MAXATTS
 res=. ":i.0 0
 for. i.y do.     NB. generate y lines
   randatts=. ({~  [EMAIL PROTECTED] ? #) attrlist
   randvals=. ":each (#randatts) ?MAXVAL
   res=. res,}:;randatts,.(<'='),.randvals,.<'&'
 end.
)

This was totally irrelevant to your question, but it
helped me think about your problem.

Anyways, you seem to be having a problem converting
token-identified values into position-identified values.

But you are starting out with a sequence of tokens, and
it would make sense to me to keep your intermediate
results in that form.  For example, instead of using
keepmsk, I might use keepinds:
   ]keepinds=: atts i."1 keepattributes
   ]keepinds {"1 vals,.a:

I was also tempted to mess with your definitions for atts and
vals, but I probably would have wanted to use regular
expressions there, which might have totally changed
the structure of the problem and would not have addressed
the more basic point you were asking about.

Anyways, there was nothing wrong with your approach, except
that selection masks inherently discard order that i. by
itself would keep.

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to