double quotes

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
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

double quotes

Post by pavan_test »

Hi All,

I have a file with 1 column and its data is as follows;
"Happy Hour, Party on 18"" staged on 20th."

Can anyone please suggest me how do I remove the embedded quote in data stage while reading this column.
awk or sed might be able to do the trick using external filter stage. but i am not sure how to accomplish this.

can anyone please suggest me.

Thanks
Mark
filename.txt
Participant
Posts: 27
Joined: Thu Mar 20, 2008 11:55 am

Post by filename.txt »

Try this...

sed 's/[""]//g' oldFilename>Newfilename

I missed [] in my previous post...
Last edited by filename.txt on Mon Aug 25, 2008 4:05 pm, edited 2 times in total.
Thanks.

"Creativity is the ability to use your available resources to their fullest."
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

double quotes

Post by pavan_test »

[quote="filename.txt"]Try...

sed 's/""/,//g'<oldfilename>newfilename[/quote]

it says sed: Function s/""/,//g cannot be parsed.

Thanks
Mark
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

double quotes

Post by pavan_test »

[quote="filename.txt"]Try...

sed 's/""/,//g'<oldfilename>newfilename[/quote]

it says sed: Function s/""/,//g cannot be parsed.

Thanks
Mark
filename.txt
Participant
Posts: 27
Joined: Thu Mar 20, 2008 11:55 am

Post by filename.txt »

Try this...

sed 's/[""]//g' oldFilename>Newfilename

I tested it and it should work :)

I missed [] in my previous post...
Thanks.

"Creativity is the ability to use your available resources to their fullest."
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

double quotes

Post by pavan_test »

Thank you. This is working partially.

Before;

"Happy Hour, Party on 18"" staged on 20th."

After;

Happy Hour, Party on 18 staged on 20th.

My Expected result;

Happy Hour, Party on 18" staged on 20th.

Can anyone please suggest me how do I implement this in data stage. what stage do I have to use to acomplish this.

Thanks a lot.

Thanks
Mark
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

it is quite simple. read the whole string with quotes (in the file stage set quote=none) and then in a transformer stage trim the " .
Trim(<column name>,'"')
'"' is single quote:double quote:single quote
Last edited by keshav0307 on Tue Aug 26, 2008 12:13 am, edited 1 time in total.
tkbharani
Premium Member
Premium Member
Posts: 71
Joined: Wed Dec 27, 2006 8:12 am
Location: Sydney

Post by tkbharani »

You must redirect the file output incase you opt to use sed or awk. Rather try to use perl command to find & replace in the same file without redirecting. Incase if the file is large, perl -pi will be much faster than sed.
For example try

Code: Select all

perl -pi -e 's/<old text>/<new text>/g;'
Other Option
As only one column is with quotes, you can always use datastage functions to remove special charecters , which avoids one unix script stage.
Thanks, BK
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

double quotes

Post by pavan_test »

Thanks for all the suggestions.

it is working now.

Thanks
Mark
Post Reply