From: Jeff H. <Je...@Je...> - 2022-06-18 11:47:17
|
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>Mike,</p> <p>Beautiful!</p> <p>Yes, I use CSV files in places.</p> <p>To use the stage in NetRexx Pipelines, it must be in NetRexx, an easy enough translation, and we have the promise that that won't be needed in the next release.</p> <p>Yes, you can use DIY stages in NetRexx Pipelines.<br> </p> <p>We added some stages in the 4.01 release that are not in the IBM cannon, mostly for Java convenience, but also SQL and using PARSE notation as an alternative to SPECs. I think this stage would be a great addition.</p> <p>And I like the concept for the LOCATE stage's FIELDS. <br> </p> <p>Jeff<br> </p> <div class="moz-cite-prefix">On 6/18/2022 5:49 AM, <a class="moz-txt-link-abbreviated" href="mailto:hp...@we...">hp...@we...</a> wrote:<br> </div> <blockquote type="cite" cite="mid:a40...@we...">Hi Jeff! <br> <br> Am 18.06.2022 um 00:56 schrieb Jeff Hennick: <br> <blockquote type="cite">The WORDS option of the SPECs stage is supported in NetRexx Pipelines. FIELDS, <br> and the SEPERATORs are not yet. (WORDS uses a simple PARSE, but using a <br> non-SPACE separator will require more code, probably PARSE in a loop.) <br> </blockquote> <br> More code for sure, but PARSE in a loop? How about masking blanks, <br> if there are more word-separators mask them too, change the fs to <br> blank, parse "words" as you are used to, and undo all masking. <br> Drawback: chars used for masking must not exist in input, else you <br> have a problem. But, IMO, it's worth it, otherwise, how do you <br> handle CSV files? <br> <br> CSV files? Yes, this "simple as that"-format for tables. It would <br> be my next challenge after the OS/2 to NetRexx migration. Is it <br> possible to run such "DIY" stages in NetRexx Pipelines: <br> <br> <blockquote type="cite">/* CSVCLN REXX: brush-up a CSV file */ <br> /* (CSV = character separated values, a table transfer format) */ <br> /* Operation: change separating comma to TAB, single doubled quotes */ <br> /* and strip quotes from quoted values */ <br> /* */ <br> /* Ð×××××××××××××××××××××××××××××××××××××××××××××××××××××××××ׯ */ <br> /* ³ ³ */ <br> /* ³ >>××CSVCLN×ײ×××××××××××××××××××××××××××××××××××ײ××××>< ³ */ <br> /* ³ ¿××oldsep××ײ××××××××××××××××××××××ײ| ³ */ <br> /* ³ ¿××newsep××ײ×××××××××ײ| ³ */ <br> /* ³ ¿××nixbix××| ³ */ <br> /* ³ ³ */ <br> /* ¿××××××××××××××××××××××××××××××××××××××××××××××××××××××××××| */ <br> /* */ <br> /* OLDSEP specify the separation character used in input CSV, */ <br> /* default is comma (,) */ <br> /* NEWSEP define the separation character in output, */ <br> /* default is TAB (hex 05) */ <br> /* (OLDSEP and NEWSEP may be defined in hex or as a single */ <br> /* character, but % or § will fail) */ <br> /* NIXBIX is used as a place-holder for treatment of double quotes */ <br> /* its occurrence in input is not tested */ <br> /* Note: if you specify a wrong OLDSEP, output is chopped at quotes */ <br> /* .....Mike 190299 */ <br> /* ----------------------------------------------------------------- */ <br> /* Change 050799: Now doubled speed by Melinda's suggestion. */ <br> /* Note 1: Now a wrong OLDSEP will chop at leading quotes. */ <br> /* Note 2: Now two new "nixbix" are hardcoded: x00 and x01 should */ <br> /* not occur in input. */ <br> /* ----------------------------------------------------------------- */ <br> trace o /* in case of stall */ <br> signal on novalue /* No uninitialised variables */ <br> signal on failure /* Allow RC > 0 for a moment */ <br> 'STAGENUM' /* Where are we? */ <br> first? = RC = 1 /* first or not? */ <br> 'MAXSTREAM IN' /* Check only one stream */ <br> signal on error /* now stop for any error */ <br> if RC ^= 0 then 'ISSUEMSG 264 PIPCSV' /* too many streams: crash */ <br> if first? then 'ISSUEMSG 127 PIPCSV' /* if first: stop and say why */ <br> parse arg oc nc ph z /* args in mixed case */ <br> if z ^='' then 'ISSUEMSG 111 PIPCSV "' z '"' /* too many args */ <br> if oc = '' then oc = ',' /* default old sep char */ <br> else do /* user defined sep char */ <br> oc = strip(oc) /* no blanks arround it */ <br> l = length(oc) /* how many letters? */ <br> select /* marginal test */ <br> when l = 1 then nop /* a single character is ok */ <br> when l = 2 then oc = x2c(oc) /* hex assumed */ <br> otherwise 'ISSUEMSG 50 PIPCSV "' oc '"' /* invalid argument: stop */ <br> end; end /* end Select and Else Do */ <br> if nc = '' then nc = '05'x /* default new sep char */ <br> else do /* user defined sep char */ <br> nc = strip(nc) /* no blanks around it */ <br> l = length(nc) /* how many letters? */ <br> select /* marginal test */ <br> when l = 1 then nop /* a single character is ok */ <br> when l = 2 then nc = x2c(nc) /* hex assumed */ <br> otherwise 'ISSUEMSG 50 PIPCSV "' nc '"' /* invalid argument: stop */ <br> end; end /* end Select and Else Do */ <br> if ph = '' then ph = 'NixBix' /* default place holder for "" */ <br> 'CALLPIPE (sep % end § name CSVCLN.REXX) *:', /* ------- in ------ */ <br> '% change /""""/'ph'/', /* single inch-sign */ <br> '% change /'oc'"""/'oc'"'ph'/', /* leading inch-sign */ <br> '% change 1.3 /"""/"'ph'/', /* same in fst column */ <br> '% change /'oc'""/'oc'/', /* empty cells */ <br> '% change 1.2 /""//', /* same in fst column */ <br> '% change /""/'ph'/', /* example: "zizu = 8"" etc." */ <br> '% strip trailing' oc, /* no empty cells at end of record */ <br> '% xlate 1-* 40 00', /* Mask the blanks. */ <br> '% tokenize /"/ x01', /* Tokenize and delimit. */ <br> '%q:outside /"/ /"/', /* branch quoted values */ <br> '% xlate 1-*' oc nc, /* replace old by new sep-char */ <br> '%f:faninany', /* collect all parts of record */ <br> '% deblock linend 01 terminate', /* Re-form original records. */ <br> '% change /'ph'/"/', /* place holder to inch-sign */ <br> '% xlate 1-* 00 40', /* Unmask the blanks. */ <br> '%*:', /* ----------- out ----------- */ <br> '§q:', /* from OUTSIDE */ <br> '% nfind "' !!, /* Get rid of the quotes. */ <br> '%f:' /* to FANINAY */ <br> failure:; error: exit (RC * (RC ^= 12 & RC ^= 8)) /* RC = 0 if EOF */ <br> </blockquote> <br> I'm retired, so I stipulate as license: don't ask, don't tell ;) <br> (Alter codepage for nice railroad tracks in header.) <br> <br> I hope your answer will be 'yes, no problem.' <br> <br> Best, <br> M. <br> <br> <br> <br> _______________________________________________ <br> netrexx-pipelines mailing list <br> <a class="moz-txt-link-abbreviated" href="mailto:net...@li...">net...@li...</a> <br> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/netrexx-pipelines">https://lists.sourceforge.net/lists/listinfo/netrexx-pipelines</a> <br> </blockquote> </body> </html> |