The zeros are indeed "fill" that J uses to make a rectangular array:
9 9 9 , 9 9 9 9 9 9 , 9 9 9 9 ,: 9 9 9 9 9
9 9 9 0 0 0
9 9 9 9 9 9
9 9 9 9 0 0
9 9 9 9 9 0
See:
http://www.jsoftware.com/help/jforc/loopless_code_i_verbs_have_r.htm#_Toc191734337
If you look at either RE Boss' or Marshall's boxed representation of
_&".;._2 T then you will see that the boxed lines are of different
length, which will cause the issue above when they are unboxed. The
solution is for the verb to the left of Cut (;.) to make the result
rows equal length. The boxed representations show that the last 4
members of each box are the required numeric values so the simplest
way was to take the last 4 members of each fret delimited sequence.
This is equivalent to the original solution with explicit boxing & unboxing.
_4&{.&> <@(_&".) ;._2 T
2010/12/21 Björn Helgason <[email protected]>:
> The zero at the end is there for a different reason
>
> ( _&".) ;._2 T
> _ _ _ _ _ _ _ _ 9065 134.7 67.3 2.3 0
> _ _ _ _ _ _ _ _ _ 12012 158.9 75.6 3.1
> _ _ _ _ _ _ _ _ 15055 198.6 75.8 2.8 0
> _ _ _ _ _ _ _ _ _ 16687 238.9 69.8 2.8
> _ _ _ _ _ _ _ _ 9801 117.1 83.7 3.4 0
>
> (_4 {. _&".) ;._2 T
> 9065 134.7 67.3 2.3
> 12012 158.9 75.6 3.1
> 15055 198.6 75.8 2.8
> 16687 238.9 69.8 2.8
> 9801 117.1 83.7 3.4
>
> I still think it is good to come up with this solution
>
> 2010/12/20 Marshall Lochbaum <[email protected]>
>
>> The 0 is just fill:
>>
>> ,. ([: < 0&".) ;._2 T
>> ┌──────────────────────────────────────┐
>> │0 0 0 0 0 0 0 0 9065 134.7 67.3 2.3 │
>> ├──────────────────────────────────────┤
>> │0 0 0 0 0 0 0 0 0 12012 158.9 75.6 3.1│
>> ├──────────────────────────────────────┤
>> │0 0 0 0 0 0 0 0 15055 198.6 75.8 2.8 │
>> ├──────────────────────────────────────┤
>> │0 0 0 0 0 0 0 0 0 16687 238.9 69.8 2.8│
>> ├──────────────────────────────────────┤
>> │0 0 0 0 0 0 0 0 9801 117.1 83.7 3.4 │
>> └──────────────────────────────────────┘
>>
>> Another option is to remove all the 0s after execution with -. :
>>
>> (0 -.~ 0&".) ;._2 T
>> 9065 134.7 67.3 2.3
>> 12012 158.9 75.6 3.1
>> 15055 198.6 75.8 2.8
>> 16687 238.9 69.8 2.8
>> 9801 117.1 83.7 3.4
>>
>> For this you might want to use _ in case there are zeros in the data.
>>
>> Marshall
>>
>> -----Original Message-----
>> From: [email protected] [mailto:
>> [email protected]] On Behalf Of Björn Helgason
>> Sent: Monday, December 20, 2010 4:50 AM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Extracting data from a text
>>
>> This is brilliant!
>>
>> Would be interesting to note how you thought it out.
>>
>> Especially because an ordinary split leaves an extra 0 at the end in some
>> of
>> the lines.
>>
>> ( 0&".) ;._2 T
>> 0 0 0 0 0 0 0 0 9065 134.7 67.3 2.3 0
>> 0 0 0 0 0 0 0 0 0 12012 158.9 75.6 3.1
>> 0 0 0 0 0 0 0 0 15055 198.6 75.8 2.8 0
>> 0 0 0 0 0 0 0 0 0 16687 238.9 69.8 2.8
>> 0 0 0 0 0 0 0 0 9801 117.1 83.7 3.4 0
>>
>>
>> 2010/12/19 Tikkanz <[email protected]>
>>
>> > Something like this?
>> >
>> > (_4 {. 0&".) ;._2 T
>> >
>> > Ric
>> >
>> > On Mon, Dec 20, 2010 at 11:03 AM, Bo Jacoby <[email protected]> wrote:
>> > > I need elementary advice. Please help me.
>> > >
>> > > I have a text T, retrieved by cut and past from a pdf-document, like
>> > this:
>> > >
>> > > T =. 0 : 0
>> > > SN 1990O . . . . . . 9065 134.7 67.3 2.3
>> > > SN 1990T . . . . . . . 12012 158.9 75.6 3.1
>> > > SN 1990af . . . . . . 15055 198.6 75.8 2.8
>> > > SN 1991S . . . . . . . 16687 238.9 69.8 2.8
>> > > SN 1991U . . . . . . 9801 117.1 83.7 3.4
>> > > )
>> > >
>> > > How to produce a 5 row 4 column array containing the numeric data from
>> T?
>> > >
>> > > - Bo
>> > >
>> > >
>> > >
>> > >
>> > > ----------------------------------------------------------------------
>> > > For information about J forums see http://www.jsoftware.com/forums.htm
>> > >
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> >
>>
>>
>>
>> --
>> Björn Helgason, Verkfræðingur
>> Fornustekkum II
>> 781 Hornafirði,
>> t-póst: [email protected]
>> gsm: +3546985532
>> sími: +3544781286
>> http://groups.google.com/group/J-Programming
>>
>>
>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>>
>> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>> /|_ .-----------------------------------.
>> ,' .\ / | Með léttri lund verður |
>> ,--' _,' | Dagurinn í dag |
>> / / | Enn betri en gærdagurinn |
>> ( -. | `-----------------------------------'
>> | ) | (\_ _/)
>> (`-. '--.) (='.'=) ♖♘♗♕♔♙
>> `. )----' (")_(") ☃☠
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
> --
> Björn Helgason, Verkfræðingur
> Fornustekkum II
> 781 Hornafirði,
> t-póst: [email protected]
> gsm: +3546985532
> sími: +3544781286
> http://groups.google.com/group/J-Programming
>
>
> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>
> góður kennari getur stigið á tær án þess að glansinn fari af skónum
> /|_ .-----------------------------------.
> ,' .\ / | Með léttri lund verður |
> ,--' _,' | Dagurinn í dag |
> / / | Enn betri en gærdagurinn |
> ( -. | `-----------------------------------'
> | ) | (\_ _/)
> (`-. '--.) (='.'=) ♖♘♗♕♔♙
> `. )----' (")_(") ☃☠
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm