View previous topic :: View next topic
Author
Message
Gary McDowell Active User Joined: 15 Oct 2012Posts: 139 Location: USA
I'm trying to create an Excel comma-delimited file with SyncSort. The data also has commas in it so I needed to add double-quotes around the fields along with the comma. Now the issue I have is the output has no double-quote in col-1, and an extra quote at end.
Any help/suggestions would be appreciated (yes, I've been looking at the SyncSort manuals). Thanks.
Input:
Code:
1111~222~2015-02-28~
9999999999~JONES & ASSOCIATES, DDS, PA~P O BOX 123~~AAAAAAAAAA~
//SYSIN DD *
Code:
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,VTOF,OUTREC=(5,3000)
OUTREC FINDREP=(INOUT=(C'~',C'","',
C'" ',C' '))
Sample of what I am getting (no double-quote in col-1, and an extra quote at end):
Code:
1111","2222","2015-02-28","
9999999999","JONES & ASSOCIATES, DDS, PA","P O BOX 123","","AAAAAAAAAA","
Sample of what it should look like:
Code:
"1111","2222","2015-02-28",
"9999999999","JONES & ASSOCIATES, DDS, PA","P O BOX 123","","AAAAAAAAAA",
Back to top
RahulG31 Active User Joined: 20 Dec 2014Posts: 446 Location: USA
Try using INREC FINDREP and then use OUTREC BUILD to do whatever formatting you want.
Something like this:
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,VTOF
INREC FINDREP=(INOUT=(C'~',C'","',
C'" ',C' '))
OUTREC BUILD=(1:C'"',2:5,3000)
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'~',C'","',))),
IFTHEN=(WHEN=INIT,
BUILD=(1,4,C'"',5)),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'" ',C' ')))
OUTFIL VTOF,OUTREC=(5,3000)
The BUILD takes care of the first problem. You have to insert a character, because there is nothing to change.
Your other problem is that the output from one FINREP change cannot be further changed in the same FINDREP. So you need a second FINDREP.
It doesn't matter in what order you specify them, OUTFIL is always going to be done last. So specify it last anyway.
Back to top
Gary McDowell Active User Joined: 15 Oct 2012Posts: 139 Location: USA
Thanks Bill and RahuG31.
Almost!
Only the last IFTHEN to change the double-quote with a space did not work and I think I know why.
The input is variable-length and the last double-quote has no spaces after it so it's never found.
Input in hex:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
1111~222~2015-02-28~
FFFFAFFFAFFFF6FF6FFA
11111222120150020281
--------------------------------------------------------------------------------
9999999999~JONES & ASSOCIATES, DDS, PA~P O BOX 123~~AAAAAAAAAA~
FFFFFFFFFFADDDCE454CEEDCCCECE64CCE64DCAD4D4CDE4FFFAACCCCCCCCCCA
99999999991165520001226391352B0442B0711706026701231111111111111
--------------------------------------------------------------------------------
I tried replacing the last IFTHEN with the following but got the same double-quote at the end:
Code:
OUTREC IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'" ',C' ')))
OUTREC FINDREP=(INOUT=(C'" ',C' '))
I then tried googling for a way I could change the last input '~' or last output '"'. Nothing yey.
Any suggestions?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Your diagnosis is correct.
Sorry, I "tested" it with fixed input :-)
Change this:
Code:
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'" ',C' ')))
To this:
Code:
IFTHEN=(WHEN=INIT,
OVERLAY=(3005:X)),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'" ',C' '),
DO=1))
At the moment you are extending any records shorter than 3000 in length of data on the OUTFIL, and they get padded with space. No problem (since there is no SORT) in doing it in INREC before the second FINDREP. Then there is only one change you need, so put the DO=1 to prevent the FINDREP searching the entire 3000 bytes (for a variable-length record, FINDREP starts at position five and is limited by the record-length in the RDW, which SORT will automatically increase after the OVERLAY).
If there were a SORT involved, you'd do this all in OUTREC, which would be after the SORT is complete, to limit the amount of data sorted.
Back to top
Gary McDowell Active User Joined: 15 Oct 2012Posts: 139 Location: USA
Perfect! Thank you Bill. I like how that DO=1 works.
Are there any links/books you would recommend for SYNCSORTs?
Thanks again.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
SyncSort documentation is proprietary, but you can get copies easily if your site is licensed to use the product.
There is no SyncTool documentation. According to Dave Porcelan, SyncSort Support suggest using the DFSORT documentation for ICETOOL.
There are various DFSORT papers which will be useful and largely work on SyncSort, but be careful not to miss out on SyncSort-only stuff.
There is a new SyncSort available, 2.1. There are some papers at syncsort.com, but I've not looked at them yet.
Back to top
Gary McDowell Active User Joined: 15 Oct 2012Posts: 139 Location: USA
Bill Woodger wrote:
SyncSort documentation is proprietary, but you can get copies easily if your site is licensed to use the product.
There is no SyncTool documentation. According to Dave Porcelan, SyncSort Support suggest using the DFSORT documentation for ICETOOL.
There are various DFSORT papers which will be useful and largely work on SyncSort, but be careful not to miss out on SyncSort-only stuff.
There is a new SyncSort available, 2.1. There are some papers at syncsort.com, but I've not looked at them yet.
I'll take your suggestions. Thanks Bill.
Back to top
Please enable JavaScript!