Page 1 of 1

Facing Issue while sending a delimited mainfr file to CSV

PostPosted: Sat Oct 22, 2016 4:38 am
by dkuma14
Hello everyone,

It will be great if anyone could suggest me on my below query.

I have a jcl which is sending a delimited (delimited by , ) mainframe PS file as .CSV in email.

What happening is one of the field of file is have , within it, so in excel it getting separated bcz it is treated as delimiter but actually it is not. I need whole record together
of that fields.

I have attached my delimited mainframe file and the screenshot of excel which actually I am getting and I have also attached what I am expecting, that screenshot will more clear it actually what my concern is.


Thanks for looking into this.

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 4:41 am
by BillyBoyo
You need to "protect" the field with a double-quote prior to the first character of the field and after the last

A,"1,234.00",B

That will only be three fields.

Note, you also need to protect the protector:

A,"XY"Z",B

Whatever reads the CSV will understand this, stripping the first and last ", and not using the comma or quote within such a field to mess things up.

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 6:10 am
by dkuma14
@Billy boyo .. Thanks for your suggetsion

I tried as you suggested but still I am not getting expected result.

Please look into the attachment.

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 6:37 am
by Akatsukami
Why do you not copy-and-paste from your terminal emulator instead wasting space with attachments?

Incidentally, you appear not to be using double-quotes, but two single-quotes (or pics).

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 6:58 am
by dkuma14
I tried with double quotes also (not two single quotes) still it is coming the same way.

And I tried to insert pic in content box (here) by clicking on Img, but when I click its come like this only . Neither I am able to copy paste my image here .

So I am giving it as an attachment.

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 2:09 pm
by NicC
Highlight the part of the screen you want to copy, press ctrl-c. Put the cursor in the text box of the reply page, press ctrl-v. Highlight the text that you have just pasted and click the Code button (if using the full editor which is available via the Post Reply button) or precede the text with [code ] and terminate it with [/code ] (no spaces between 'code' and ']'.

Also, this is not a JCL question but a question for whatever software (cobol pgm, sort utility) that you are using to create the dataset (not a 'file').

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 5:34 pm
by Aki88
Hello,

Aside, positively There Is an error in the way the quotation (double-quotes) marks have been used to protect the data; you might want to revisit the same.

Here is a quick test run:

Unprotected data:


EDIT       XXXX.YYYY.ZZZZ                                 Columns 00001 00072
Command ===>                                                  Scroll ===> CSR  
****** ***************************** Top of Data ******************************
000001 THE,FIELDS,ARE,NOT,PROTECTED,HERE                                      
****** **************************** Bottom of Data ****************************
 


Gives:


THE FIELDS  ARE NOT PROTECTED   HERE  <-- the spaces are TABBED spaces from the converted .CSV file
 



Protected data:


EDIT       XXXX.YYYY.ZZZZ                                 Columns 00001 00072
Command ===>                                                  Scroll ===> CSR  
****** ***************************** Top of Data ******************************
000001 THE,FIELDS,"ARE,PROTECTED",HERE                                        
****** **************************** Bottom of Data ****************************


Gives:


THE FIELDS  ARE,PROTECTED   HERE  <-- Notice the TABBED spaces and the grouped words 'ARE,PROTECTED' here
 

Re: Facing Issue while sending a delimited mainfr file to CS

PostPosted: Sat Oct 22, 2016 7:10 pm
by dkuma14
Thanks everyone for your valuable time and help on this . It is working for me now.

Earlier I was doing same what you all have suggested but it was not working for me. So here I am writing the reason why it was not working earlier and now its worked for me. It might help someone.

Only difference was that ,earlier the field was having spaces after , before the field in which I want to use double quotes. Below is the sample for which it was not working.

***************************** Top of Data **********
 '033','80','00008',    "AK1,MA", EMI
 **************************** Bottom of Data *******


So if someone want to keep a field in double quote then starting double quote of that field should began just after the preceding , . Sample is given below which worked .
***************************** Top of Data **********
 '033','80','00008',"AK1,MA", EMI
 **************************** Bottom of Data *******


Note - If we are not using any double quotes for any fields then spaces between fields separated by comma is enough to get this result.
'033',    '80',       '00008',        AK1,     EMI


Here I have not used any double quotes so in this case spaces will not affect our result , is enough to keep fields in different column of the excel.


Again thanks to everyone for helping me.

You forgot to use the code tags. They should be used for everything that comes from your terminal. coded for you.