Page 1 of 1

Flat file to comma delimited file

PostPosted: Thu Mar 29, 2012 7:53 pm
by ctrevino
I want to use syncsort to convert a flat file to a comma delimited file.

this is my format
xxxxxx123smith john

First field 6 bytes, second field 3 bytes, last two fields both 20 bytes.

I used this parameter but it overwrote data instead of shifting it.
SORT FIELDS=COPY
INREC FIELDS=(1,6,7:C',',8,3,11:C',',12,20,32:C',',33,20)
OUTREC FIELDS=(1,37)

Help?

Christy

Re: Flat file to comma delimited file

PostPosted: Thu Mar 29, 2012 8:06 pm
by BillyBoyo
Your are showing name-looking data, so I guess you have two variable-length fields which you want to put into a fixed format.

You need to look at PARSE. You'll find examples in the forum, or using google, or consulting your manual. Maybe even some of your colleagues have used it.

What do you have as your algorithm for making the split? Names can be curious things.

Re: Flat file to comma delimited file

PostPosted: Thu Mar 29, 2012 9:25 pm
by Alissa Margulies
PARSE is used to create fixed-length fields from variable-position and variable-length fields. I'm not convinced that this is the answer.

Christy - please provide sample input records and sample records of your desired output. This will better help us determine exactly what you are attempting to accomplish. Thank you.

Re: Flat file to comma delimited file

PostPosted: Thu Mar 29, 2012 9:56 pm
by BillyBoyo
Sorry Alissa. I just "quoted and coded" and the fields are already fixed (in as much as one example can show that). Sorry for not checking earlier, as you probably did.

Re: Flat file to comma delimited file

PostPosted: Fri Mar 30, 2012 12:49 am
by ctrevino
sorry. my example got squished on me.

Here is an example:

XXXXXXAAAFFFFFFFFFFFFFFFFFFFFLLLLLLLLLLLLLLLLLLLL

I need commas in between the fields without loss of data. No comma at end.

My code is overlaying like this:
XXXXX,AA,FFFFFFFFFFFFFFFFFFFFF,LLLLLLLLLLLLLLLLLL

Re: Flat file to comma delimited file

PostPosted: Fri Mar 30, 2012 1:42 am
by Alissa Margulies
Hello Christy.

If you just want to insert commas between fixed-length fields, then try the following:

//STEP1 EXEC PGM=SORT                               
//SYSOUT  DD SYSOUT=*                               
//SORTIN  DD *                                       
XXXXXXAAAFFFFFFFFFFFFFFFFFFFFLLLLLLLLLLLLLLLLLLLL   
//SORTOUT DD SYSOUT=*                               
//SYSIN   DD *                                       
   SORT FIELDS=COPY                                 
   OUTREC BUILD=(1,6,C',',7,3,C',',10,20,C',',30,20)
/*                                                   

Here is the output produced by the above step:
XXXXXX,AAA,FFFFFFFFFFFFFFFFFFFF,LLLLLLLLLLLLLLLLLLLL

Re: Flat file to comma delimited file

PostPosted: Fri Mar 30, 2012 5:25 pm
by ctrevino
worked perfect. Thanks.:)