My problem is essentially to give an input file and the column widths and get 
it split up properly. I asked about it on the code review stack exchange site, 
but there doesn't seem to be much traffic there, so I figured maybe I could get 
a few eyes without annoying too many people reposting here.

https://codereview.stackexchange.com/questions/180633/parsing-fixed-width-format-with-j
 
<https://codereview.stackexchange.com/questions/180633/parsing-fixed-width-format-with-j>

The solution I hacked up is this:

parseFW =: dyad def '(+/ (0,+/\x) ="(0 1) i. (+/x)) <;.1 y'"(_ _1)

Usage then looks like this:

 (20 10 12) parseFW  1 42 $ 'John Smith          WA        418-Y11-4111'

I find this works, at least for the simple cases I have thrown at it so far, 
but I can't help but feel there's too much happening here for something fairly 
simple. I know where the frets are the rest is just encoding them. In 
particular it felt like the inverse of I. should be helpful but I didn't get 
that working.

If there's a library that does this, I'd probably rather use that, but I didn't 
see one at first blush.

Input greatly appreciated! Thanks,

-- 
Daniel Lyons




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

Reply via email to