View previous topic :: View next topic
Author
Message
ssuthagar New User Joined: 03 Oct 2017Posts: 6 Location: United States
Hi Seniors,
My requirement is to parse CSV file with 1020 columns and I know that I can parse only 1000 columns in a sort card.
It is a VB file since the data may not be available for all columns but the delimiters are available.
I would really appreciate if someone can help me to resolve this situation.
Note: - I am trying to split a file based on delimiter with 1000 columns.
Thanks,
Suthagar
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1338 Location: Bamberg, Germany
You can try processing in two passes with JOINKEYS (F1 and F2 have exactly the same input). See the following sample:
Code:
//PARSEMAX EXEC PGM=SORT
//F1 DD *
A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;0;1;2;3;4;5;6;7;
/*
//F2 DD *
A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;0;1;2;3;4;5;6;7;
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(81,8,A),TYPE=V,SORTED
JOINKEYS F2=F2,FIELDS=(81,8,A),TYPE=V,SORTED
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,34,F2:1,34)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%000=(ENDBEFR=C';',FIXLEN=2,REPEAT=17)),
BUILD=(%000,
%001,
%002,
%003,
%004,
%005,
%006,
%007,
%008,
%009,
%010,
%011,
%012,
%013,
%014,
%015,
%016,
81:SEQNUM,8,ZD))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%=(ABSPOS=35),
%000=(ENDBEFR=C';',FIXLEN=2,REPEAT=17)),
BUILD=(%000,
%001,
%002,
%003,
%004,
%005,
%006,
%007,
%008,
%009,
%010,
%011,
%012,
%013,
%014,
%015,
%016,
81:SEQNUM,8,ZD))
END
/*
Output:
Code:
****** **************************** Datenanfang **************************
000001 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7
****** **************************** Datenende ****************************
Back to top
ssuthagar New User Joined: 03 Oct 2017Posts: 6 Location: United States
Thanks Jeorg,
Actually mine is a single CSV file which contains 1020 columns, With headers are detailed records and all are delimited by ",".
Detail records will not have a value for all 1020 columns and I need to parse it out to its positions to process.
I am really sorry, I am not getting your response for my question.
Thanks,
Suthagar
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2145 Location: USA
Joerg.Findeisen wrote:
You can try processing in two passes with JOINKEYS (F1 and F2 have exactly the same input). See the following sample:
Code:
PARSE=(%=(ABSPOS=35),
“Some fields can be missing” <-> fixed position will not work...
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2145 Location: USA
ssuthagar wrote:
Thanks Jeorg,
Actually mine is a single CSV file which contains 1020 columns, With headers are detailed records and all are delimited by ",".
Detail records will not have a value for all 1020 columns and I need to parse it out to its positions to process.
I am really sorry, I am not getting your response for my question.
Thanks,
Suthagar
The answer by Joerg is clear enough for the Expert Forum.
Since it doesn’t work for you, I recommend to move your discussion to the Beginners Forum.
Back to top
ssuthagar New User Joined: 03 Oct 2017Posts: 6 Location: United States
Thanks for your response Sergeyken,
I did not see the beginners forum in Home. Can you please share the link for the beginners forum.
Thanks in advance,
Suthagar
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2145 Location: USA
ssuthagar wrote:
Thanks for your response Sergeyken,
I did not see the beginners forum in Home. Can you please share the link for the beginners forum.
Thanks in advance,
Suthagar
www.ibmmainframeforum.com/
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1338 Location: Bamberg, Germany
sergeyken wrote:
Joerg.Findeisen wrote:
You can try processing in two passes with JOINKEYS (F1 and F2 have exactly the same input). See the following sample:
Code:
PARSE=(%=(ABSPOS=35),
“Some fields can be missing” <-> fixed position will not work...
Yes, that's true.
Another quick update to parse 6 fields each to FIXLEN=8, in two passes:
Code:
//PARSEMAX EXEC PGM=SORT
//F1 DD *
Any Data,or,none,at,all,,this, will,work.,2020,09,21
/*
//F2 DD *
Any Data,or,none,at,all,,this, will,work.,2020,09,21
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(129,8,A),TYPE=V,SORTED
JOINKEYS F2=F2,FIELDS=(129,8,A),TYPE=V,SORTED
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,128)
INREC IFTHEN=(WHEN=INIT,
PARSE=(%=(ABSPOS=50),
%000=(ENDBEFR=C',',FIXLEN=8,REPEAT=6)),
BUILD=(1,48,%000,%001,%002,%003,%004,%005))
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%000=(ENDBEFR=C',',FIXLEN=8,REPEAT=6),
%999=(SUBPOS=1,FIXLEN=80)),
BUILD=(%000,%001,%002,%003,%004,%005,%999,
129:SEQNUM,8,ZD))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(129:SEQNUM,8,ZD))
END
/*
Output:
Code:
****** **************************** Datenanfang ********************************************************
000001 Any Dataor none at all this will work. 2020 09 21
****** **************************** Datenende **********************************************************
It could be done with two separate steps as well.
Back to top
Rohit Umarjikar Global Moderator Joined: 21 Sep 2010Posts: 3076 Location: NYC,USA
What makes you not write a COBOL program ?
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2145 Location: USA
Rohit Umarjikar wrote:
What makes you not write a COBOL program ?
My personal reason not to use COBOL whenever possible:
In average 30-50 pages of code, plus multiple preparation steps are required to get the result like “2+2=?”
Back to top
Nic Clouston Global Moderator Joined: 10 May 2007Posts: 2454 Location: Hampshire, UK
Topic locked. A suitable solution has been posted in the Beginner's Forum.
Back to top
Please enable JavaScript!