Page 1 of 1

Put quotes around fields in sequential file only with commas

Posted: Fri Mar 08, 2019 5:40 am
by jweir
Hi All,

I am having trouble putting double quotes around a field when writing to a sequential file when the field contains a comma. The file itself is a CSV. So if the field does not contain a comma within it, it shouldn't be enclosed within double quotes, but when the field does contain a comma, it should be.

Thanks in advance.

Posted: Sat Mar 09, 2019 3:08 am
by chulett
So... this is a DataStage question? As in you're having this issue with the Sequential File stage in a parallel job? Just wanted to double-check since the question was pretty generic. In any case, I am wondering why you are worried about the quotes, specifically the need to only have them when there's a comma in the data. Would having them there all the time cause a problem? It doesn't really seem like something to me that you should be worried about.

The only other clarification would be the "contains a comma" statement. Not could contain but actually does contain, as in a record by record check of the actual data? One record might have quotes around field X while the next record may not, in other words. Perhaps over-thinking things a bit this morning but looking to define the scope of the issue if we move forward with it.

Posted: Mon Mar 11, 2019 11:27 pm
by mouthou
Question/scenario makes the brain to wander a little bit! In future, putting some sample input and expected output will help.

Is this your clarification on when the quotes will be put by DataStage. Are you creating the file by using SeqFile stage in which you will get quotes for all fields and not face the particular issue which you explained?