Thinking outside the box, the real comma of importance is always between two 
double-quotes, right?  Ala:  "Field1 data","Field 2 data, with a comma, and 
another comma","Field3 data","and so on"
How about a simple stage: | CHANGE /","/"~"/
or to some other character known to not be in the text (perhaps '00'x)?  Then 
process the records using the new FS character.  Should be a lot cheaper than 
your uncsv rexx stage.

Mike Walter
Aon Service Corporation
The opinions expressed herein are mine alone, not necessarily those of my 
employer.

-----Original Message-----
From: CMSTSO Pipelines Discussion List [mailto:[email protected]] On 
Behalf Of James Vincent
Sent: Thursday, August 20, 2015 10:03
To: [email protected]
Subject: Re: CSV data specs

The "bazillion data records" throws a wrench into that.  I have a "uncsv rexx" 
routine that does basically that record-by-record, but it seems expensive.

/* Make a CSV format into a simple Field Separated string        */
Arg breakchar .
If breakchar = '' Then breakchar = '05'x

Signal ON ERROR
Do Forever
  'READTO INREC'
  'CALLPIPE VAR INREC |',
    'SPLIT |',                       /* remove extra blanks quickly */
    'JOIN * ¤ ¤ |',
    'SPLIT BEFORE STRING ¤,"¤ |',
    'CHANGE FS " F3 ¤,¤ ¤,""¤ |',    /* Change empty fields to "" */
    'JOIN * |',
    'CHANGE FS " F1 ¤,¤ ¤"",¤ |',
    'SPLIT AT STRING ¤",¤ |',
    'CHANGE 1.1 ¤"¤ ¤¤ |',
    'CHANGE -1 ¤"¤ ¤¤ |',
    'JOIN * ¤'||breakchar||'¤ |',
    '*:'
  End
Signal EXIT
ERROR:
If rc = 12 Then Signal EXIT
EXIT:
Exit rc*(rc\=12)

-- *James Vincent*

On Thu, Aug 20, 2015 at 10:55 AM, Rich Smrcina <[email protected]> wrote:

> Do a split at ," then join them back together.
>

Reply via email to