CSV file with delimiter other than comma

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Gopinath
Participant
Posts: 52
Joined: Wed Apr 25, 2007 2:18 am
Location: Chennai

CSV file with delimiter other than comma

Post by Gopinath »

Is it possible to create a CSV file with the delimiter other than comma. If its possible, can anybody let me know the option to be used and the delimiter?

Thanks..
Gopinath
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

In the sequential file "Format" tab, select Field defaults -> Delimiter to be a value other than the default "comma".
Gopinath
Participant
Posts: 52
Joined: Wed Apr 25, 2007 2:18 am
Location: Chennai

Post by Gopinath »

ArndW wrote:In the sequential file "Format" tab, select Field defaults -> Delimiter to be a value other than the default "comma". ...
If you specify other than comma, its creating file with incorrect values. Please see the example below.

Input:
col1 col2 col3
ABC A,B ABC

Output should be like below,
col1 col2 col3
ABC A,B ABC

My output file is CSV file hence we cannot give other than comma as a delimiter.

Output with delimiter as comma: If i give comma, its created like below,

col1 col2 col3
ABC A B ABC

Output with delimiter other than comma: If you give other than comma as a delimiter, then its giving like,

col1 col2 col3
ABC A
Gopinath
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since your problem lies in having embedded commas, you need to ensure that your strings are quoted when writing to the sequential file.

CSV files do not need to have commas as separators, quite of semicolons are used and theoretically any separator could be used.

what did you specify as your separator instead of a comma? That is not evident from your example.
Gopinath
Participant
Posts: 52
Joined: Wed Apr 25, 2007 2:18 am
Location: Chennai

Post by Gopinath »

ArndW wrote:Since your problem lies in having embedded commas, you need to ensure that your strings are quoted when writing to the sequential file.

CSV files do not need to have commas as separators, quite of semicolons are used and theoretically any separator could be used.

what did you specify as your separator instead of a comma? That is not evident from your example.
I am trying to use PIPE as delimiter.
I have tried pipe as delimiter and used the Quote function too. But the output is not generating as expected.

Note: I cannot get my input with Quote and my output file shud be a CSV file.
Gopinath
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a server job, or server Sequential File stage in a server Shared Container in a parallel job.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Gopinath
Participant
Posts: 52
Joined: Wed Apr 25, 2007 2:18 am
Location: Chennai

Post by Gopinath »

ray.wurlod wrote:Use a server job, or server Sequential File stage in a server Shared Container in a parallel job. ...
Thanks for your reply Ray...
I dont have access to use all these stages. We cant implement these stage. Is there any other way to solve the issue?
Gopinath
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Writing 3 column values of "x" "y,y," and "z" in a pipe delimited file with double quotes results in:

Code: Select all

"x"|"y,y"|"z"
When you read this using pipe delimiters and double-quotes for strings you will get exactly the same results.
Gopinath
Participant
Posts: 52
Joined: Wed Apr 25, 2007 2:18 am
Location: Chennai

Post by Gopinath »

I cant get my input with Quotes, its coming from many source tables and after transformations, writing into a sequential file as CSV file.
Gopinath
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

First off, a csv is a "Comma separated values" file. On Unix, you can create files with any name (.csv or .out etc.). But, if you import that into Windows to view it, you cannot immediately open with Excel. You have to use a text editor.
Gopinath wrote: I cant get my input with Quotes, its coming from many source tables and after transformations, writing into a sequential file as CSV file.
That is exactly what was suggested here. Even if this gets created with quotes, when you read it again in a sequential file stage with the proper settings, you should not be seeing those quotes again. The problem is that you have fields with commas as values and you have to use quotes to treat that as one. You can even use a comma as a delimiter if you are using double quotes.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
Gopinath
Participant
Posts: 52
Joined: Wed Apr 25, 2007 2:18 am
Location: Chennai

Post by Gopinath »

I have tried the option like, Delimiter as comma and Quotes=Double. It solved the Issue.

Many thanks to all of You!!
Gopinath
Post Reply