Page 1 of 1

CSV file with delimiter other than comma

Posted: Mon Oct 11, 2010 10:46 pm
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..

Posted: Tue Oct 12, 2010 3:07 am
by ArndW
In the sequential file "Format" tab, select Field defaults -> Delimiter to be a value other than the default "comma".

Posted: Tue Oct 12, 2010 3:16 am
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

Posted: Tue Oct 12, 2010 3:23 am
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.

Posted: Tue Oct 12, 2010 3:40 am
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.

Posted: Tue Oct 12, 2010 5:46 am
by ray.wurlod
Use a server job, or server Sequential File stage in a server Shared Container in a parallel job.

Posted: Tue Oct 12, 2010 6:07 am
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?

Posted: Tue Oct 12, 2010 6:48 am
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.

Posted: Tue Oct 12, 2010 7:22 am
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.

Posted: Tue Oct 12, 2010 7:59 am
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.

Posted: Thu Oct 14, 2010 7:11 am
by Gopinath
I have tried the option like, Delimiter as comma and Quotes=Double. It solved the Issue.

Many thanks to all of You!!