Page 1 of 1

Split the input file using delimiter and output only few col

PostPosted: Tue Oct 18, 2016 4:03 am
by balaryan
Hi All,

I am trying to read an input file which has a fixed length of 300 bytes and each field in a record are delimited by "|" pipe symbol. For instance

Input file:

1|232|this is great|chennai|TN|604023|04/12/2018|12321.00|12312.00|N|this is for testing only|external remarks|0|0|3|Y|N|454.00|454.00
1|1232|this is great-o-great|Pune|MA|604023|04/11/2015|321.00|122.01|Y|this is for testing only|external remarks with comments|0|0|4|Y|N|54.00|14.00
1|8059|this is amazing|banglore|KA|298923|28/04/2013|321.00|662.00|N|this is for testing|external remarks|0|0|5|Y|N|344.00|984.00
1|092334|this is outstanding data|Mumbai|MA|23908043|18/08/2016|23321.00|656262.23|Y|this is for purely for testing only|external remarks|0|0|5|N|Y|323.00|1284.00
1|332|this is super|Pune|MA|6023|06/11/2010|9032.12|1233.01|Y|this is for testing only|comments|0|0|5|Y|N|154.00|124.00


I want to include only specific FIXED columns of each record from the input file say 1st, 2nd, 4th, 5th, 6th,9th, 10th, 13th, 14th, 15th in the output file. Is there any option or way to select the records based on the column using the delimiter without fixed length record?

Kindly advice.

Re: Split the input file using delimiter and output only few

PostPosted: Tue Oct 18, 2016 4:20 am
by balaryan
balaryan wrote:Hi All,

I am trying to read an input file which has a fixed length of 300 bytes and each field in a record are delimited by "|" pipe symbol. For instance

Input file:

1|232|this is great|chennai|TN|604023|04/12/2018|12321.00|12312.00|N|this is for testing only|external remarks|0|0|3|Y|N|454.00|454.00
1|1232|this is great-o-great|Pune|MA|604023|04/11/2015|321.00|122.01|Y|this is for testing only|external remarks with comments|0|0|4|Y|N|54.00|14.00
1|8059|this is amazing|banglore|KA|298923|28/04/2013|321.00|662.00|N|this is for testing|external remarks|0|0|5|Y|N|344.00|984.00
1|092334|this is outstanding data|Mumbai|MA|23908043|18/08/2016|23321.00|656262.23|Y|this is for purely for testing only|external remarks|0|0|5|N|Y|323.00|1284.00
1|332|this is super|Pune|MA|6023|06/11/2010|9032.12|1233.01|Y|this is for testing only|comments|0|0|5|Y|N|154.00|124.00


I want to include only specific FIXED columns of each record from the input file say 1st, 2nd, 4th, 5th, 6th,9th, 10th, 13th, 14th, 15th in the output file. Is there any option or way to select the records based on the column using the delimiter without fixed length record?

Kindly advice.


Also I missed one info. Last field in each record will be having either 'Y' or 'N'. Based on the value, if it is 'Y', we should place the record with specific column in output file 1 and if it is 'N' means output file 2.

Re: Split the input file using delimiter and output only few

PostPosted: Tue Oct 18, 2016 11:41 am
by BillyBoyo
Look at PARSE.

Re: Split the input file using delimiter and output only few

PostPosted: Tue Oct 18, 2016 1:12 pm
by enrico-sorichetti
Last field in each record will be having either 'Y' or 'N'

looks like You posted the wrong records...

Re: Split the input file using delimiter and output only few

PostPosted: Tue Oct 18, 2016 3:02 pm
by NicC
Do you mean columns or fields? In each case in yuor sample the second column is the pipe character.

Re: Split the input file using delimiter and output only few

PostPosted: Tue Oct 18, 2016 9:01 pm
by balaryan
Yeah Billy. I got it. with PARSE we can achieve it. Thanks for your time.

@ Nic, i meant fields. Each fields are delimited by pipe symbol.

Thanks anyways.