You can use 'b' fread to read the text file into boxes, then remove
unwanted lines, e.g. read and remove empties:

   a: -.~ 'b' fread '~bin/profile.ijs'

On Sun, Mar 26, 2023 at 11:48 PM Raul Miller <[email protected]> wrote:
>
> I think boxing each line and discarding the unwanted lines is a good
> approach here.
>
> For example:
>    (#~ *@#@-.&(' ',TAB)@>)cutLF d
>
> That said, I guess you could do something like this:
>
>    require'regex'
>    ,d rxfrom~'^.*\S.*$' rxmatches d
>
> Or, equivalently:
>    require'regex'
>   ,(rxfrom~'^.*\S.*$'&rxmatches) d
>
> I hope this helps,
>
> --
> Raul
>
> On Mon, Mar 27, 2023 at 12:28 AM More Rice <[email protected]> wrote:
> >
> > Hello,
> >
> > Goal: read from an ascii input text file, skipping all whitespace lines
> > (any number of them), and only store text lines in boxes.
> >
> > For example below, only line 3 and 4 should be stored in boxes (vim
> > test.txt, :set nu list):
> >
> > 1 $
> > 2 ^I$
> > 3 Line #3. Line #1 is LF, and line #2 is a TAB + LF.$
> > 4 Line #4. Below, line 5 is a TAB + LF; line 6 is space<TAB>space.$
> > 5 ^I$
> > 6  ^I $
> > 7 $
> >
> >
> > I looked at the stdlib, but I couldn't find a verb or a combination of them
> > to do the job cleanly. I ended up hacking (incorrect logic) like the
> > following:
> >
> > d =. fread < 'test.txt'
> > b =. LF splitstring d
> > # each b
> >
> > +-+-+--+--+-+-+-+-+
> > |0|1|50|64|1|3|0|0|
> > +-+-+--+--+-+-+-+-+
> >
> > ] lines =. > (3&<) each # each b
> >
> > 0 0 1 1 0 0 0 0
> >
> > lines # b
> >
> >
> > Ques is, is there a better (and proper) way?
> >
> >
> > thanks.
> > Maurice
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> 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