🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: bit.listserv.tsorexx
4 messages
4 total messages Started by Walter Pachl Sun, 28 Apr 2013 20:47
Re: better parsing algorithm?
#160
Author: Walter Pachl
Date: Sun, 28 Apr 2013 20:47
54 lines
3401 bytes
How about
data.=0
do i=1 By 1 While length(data) > 0
  parse var data data.i (tab) data
  end
data.0=i-1
--
Walter Pachl

---- John McKown <john.archie.mckown@GMAIL.COM> schrieb:
> I need to process some data which is generated on UNIX. The data is
> in tab separated format. That is, each element is separated by a tab
> (x'05' in EBCDIC). What I'm doing is similar to:
>
> tab='05'x
> /* assume data is in non-stem variable data */
> /* I will put each value in data.n where n starts at 1 */
> data.0=0
> i=0
> do while length(data) > 0
>      i=i+1
>      parse var data value (tab) data
>      data.i=value
>      data.0=i
> end
>
> OK, I can tighten it up a bit by using "data.i" in the parse instead of the
> temporary variable "value". And I don't need to assign i to data.0 on
> each iteration; I could do it after the "end" of the loop. But I do this just
> in case a less knowledgeable person needs to modify the code. I,
> personally, consider it easier to understand this way. But I could be
> wrong, of course.
>
> What I am hoping for is a "better" or "more understandable" algorithm.
> No, I can't
> translate the tabs to blanks, or likely do any other type of
> translate. The values
> may legitimately have blanks as part of the value. Or even other
> characters except for tabs.
>
> --
> This is a test of the Emergency Broadcast System. If this had been an
> actual emergency, do you really think we'd stick around to tell you?
>
> Maranatha! <><
> John McKown
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions,
> send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX
Re: better parsing algorithm?
#161
Author: John McKown
Date: Mon, 29 Apr 2013 01:04
63 lines
3272 bytes
Nice. A bit shorter, but the same general algorithm. Definitely will run a
tad faster. Thanks.
On Apr 28, 2013 3:47 PM, "Walter Pachl" <christel.u.w.pachl@chello.at>
wrote:

> How about
> data.=0
> do i=1 By 1 While length(data) > 0
>   parse var data data.i (tab) data
>   end
> data.0=i-1
> --
> Walter Pachl
>
> ---- John McKown <john.archie.mckown@GMAIL.COM> schrieb:
> > I need to process some data which is generated on UNIX. The data is
> > in tab separated format. That is, each element is separated by a tab
> > (x'05' in EBCDIC). What I'm doing is similar to:
> >
> > tab='05'x
> > /* assume data is in non-stem variable data */
> > /* I will put each value in data.n where n starts at 1 */
> > data.0=0
> > i=0
> > do while length(data) > 0
> >      i=i+1
> >      parse var data value (tab) data
> >      data.i=value
> >      data.0=i
> > end
> >
> > OK, I can tighten it up a bit by using "data.i" in the parse instead of
> the
> > temporary variable "value". And I don't need to assign i to data.0 on
> > each iteration; I could do it after the "end" of the loop. But I do this
> just
> > in case a less knowledgeable person needs to modify the code. I,
> > personally, consider it easier to understand this way. But I could be
> > wrong, of course.
> >
> > What I am hoping for is a "better" or "more understandable" algorithm.
> > No, I can't
> > translate the tabs to blanks, or likely do any other type of
> > translate. The values
> > may legitimately have blanks as part of the value. Or even other
> > characters except for tabs.
> >
> > --
> > This is a test of the Emergency Broadcast System. If this had been an
> > actual emergency, do you really think we'd stick around to tell you?
> >
> > Maranatha! <><
> > John McKown
> >
> > ----------------------------------------------------------------------
> > For TSO-REXX subscribe / signoff / archive access instructions,
> > send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX
>
>

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX
Re: better parsing algorithm?
#162
Author: Paul Gilmartin
Date: Mon, 29 Apr 2013 02:08
43 lines
2952 bytes
On 2013-04-28, at 19:04, John McKown wrote:

> Nice. A bit shorter, but the same general algorithm. Definitely will run a
> tad faster. Thanks.
>  
A while back there was a tedious thread on "Performance" here.
I performed an experiment but didn't report the result.  PARSE
seems usually to be the best choice.  For example,

    parse var S . X .

is measurably faster than

    X = word( S, 2 )

The string operations would be similar; I attribute the difference
to function call overhead.


>> ---- John McKown <john.archie.mckown@GMAIL.COM> schrieb:
>>> 
>>> No, I can't
>>> translate the tabs to blanks, or likely do any other type of translate. The values
>>> may legitimately have blanks as part of the value.  Or even other characters except for tabs.
>>>  
Thanks.  I cringe whenever someone proposes a solution to any such
problem that begins: "Translate every occurrence of 'X' to some
character that doesn't otherwise occur in the input. ..."  I can't
always control what's not in the input.

It sounds as if you're dealing with exported spreadsheet data.  And
you might yet have trouble with tabs in quoted data strings:

    Field 1<TAB>"Field<TAB>2"<TAB>Field 3

Faced with such a problem lately, I exported the spreadsheet from
Star/Oracle/Open/Libre/NeoOffice as HTML.  (I parsed it with awk.)

-- gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX
Re: better parsing algorithm?
#163
Author: John McKown
Date: Mon, 29 Apr 2013 02:14
58 lines
3784 bytes
A good thought, but I generate the data myself, so I know there are no tabs
as data, only as a separator. But I will need to remember that, in the
general case. Thanks. I'm going with the parse in the better loop, I guess.
Honestly, this should be a low use application and extreme performance is
not a requirement. I am a fool for readability and performance.
On Apr 28, 2013 9:08 PM, "Paul Gilmartin" <PaulGBoulder@aim.com> wrote:

> On 2013-04-28, at 19:04, John McKown wrote:
>
> > Nice. A bit shorter, but the same general algorithm. Definitely will run
> a
> > tad faster. Thanks.
> >
> A while back there was a tedious thread on "Performance" here.
> I performed an experiment but didn't report the result.  PARSE
> seems usually to be the best choice.  For example,
>
>     parse var S . X .
>
> is measurably faster than
>
>     X = word( S, 2 )
>
> The string operations would be similar; I attribute the difference
> to function call overhead.
>
>
> >> ---- John McKown <john.archie.mckown@GMAIL.COM> schrieb:
> >>>
> >>> No, I can't
> >>> translate the tabs to blanks, or likely do any other type of
> translate. The values
> >>> may legitimately have blanks as part of the value.  Or even other
> characters except for tabs.
> >>>
> Thanks.  I cringe whenever someone proposes a solution to any such
> problem that begins: "Translate every occurrence of 'X' to some
> character that doesn't otherwise occur in the input. ..."  I can't
> always control what's not in the input.
>
> It sounds as if you're dealing with exported spreadsheet data.  And
> you might yet have trouble with tabs in quoted data strings:
>
>     Field 1<TAB>"Field<TAB>2"<TAB>Field 3
>
> Faced with such a problem lately, I exported the spreadsheet from
> Star/Oracle/Open/Libre/NeoOffice as HTML.  (I parsed it with awk.)
>
> -- gil
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions,
> send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX
>

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LISTSERV@VM.MARIST.EDU with the message: INFO TSO-REXX
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads