Hi
my requirement data comming like this
column1
abc~cdfg~tx
add single quotes in data where ~ comes like 'abc'~'cdfg'~'tx'
In data may be n number of ~
Any helps, advices would be high appreciate.
Thank you in advance
add single quote in data
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3
- Joined: Fri May 16, 2008 3:14 pm
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can convert each "~" to "'~'" using an Ereplace() function [search the forum] and concatenate a single quote character to each end of the string.
Or, if the source is a file, you could pre-process it with a stream editor such as sed (I note you are on Windows, but assume you have MKS Toolkit or similar available).
If the source is a database table, you can use SQL functions to generate the required delimiters.
Or, if the source is a file, you could pre-process it with a stream editor such as sed (I note you are on Windows, but assume you have MKS Toolkit or similar available).
If the source is a database table, you can use SQL functions to generate the required delimiters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
HI Ray,
thanks for your reply.
in parallel i am not seeing Ereplace function. In parellel any other way to use similar function?
input and out put is a sequential file
thanks
thanks for your reply.
in parallel i am not seeing Ereplace function. In parellel any other way to use similar function?
input and out put is a sequential file
thanks
ray.wurlod wrote:You can convert each "~" to "'~'" using an Ereplace() function [search the forum] and concatenate a single quote character to each end of the string.
Or, if the source is a file, you could pre-process it with a stream editor such as sed (I note you are on Windows, but assume you have MKS Toolkit or similar available).
If the source is a database table, you can use SQL functions to generate the required delimiters.
add single quote in data
Hi,
If this is the only column available in input or if this is the only column having ~ characters coming in input , use
cat |sed "s/~/'~'/g"
in the filter command(Sequential file)
Input: abc~cdfg~tx
Output:abc'~'cdfg'~'tx
If you want the output data as 'abc'~'cdfg'~'tx', then use a stage variable say quote with value "'" and in transformer use
quote:<Input_col_name>:quote
where quote is the stage variable having value as " ' ".
Note:
[We can also include the option quote=single]
[I even tried the option squote, but if there is single quote within the field then this command adds a \ before each single quote.
i.e) input sdsdsd output : 'sdsdsd'
input sd'sd'sd output : 'sd\'sd\'sd'
]
Gurus,
Please correct me if i am wrong.
Thanks,
Savis
If this is the only column available in input or if this is the only column having ~ characters coming in input , use
cat |sed "s/~/'~'/g"
in the filter command(Sequential file)
Input: abc~cdfg~tx
Output:abc'~'cdfg'~'tx
If you want the output data as 'abc'~'cdfg'~'tx', then use a stage variable say quote with value "'" and in transformer use
quote:<Input_col_name>:quote
where quote is the stage variable having value as " ' ".
Note:
[We can also include the option quote=single]
[I even tried the option squote, but if there is single quote within the field then this command adds a \ before each single quote.
i.e) input sdsdsd output : 'sdsdsd'
input sd'sd'sd output : 'sd\'sd\'sd'
]
Gurus,
Please correct me if i am wrong.
Thanks,
Savis
Re: add single quote in data
Hi Savis,
thanks for your reply,
i given
cat |sed "s/~/'~'/g" at input level and i used "'":input_column:"'"
out put is coming correctly
but
1. when i open the input file first getting blank popup window and then able to view the data
2. job is aborted status and getting this error=> Filter status 65,280
please let me know any suggetions.
thanks
thanks for your reply,
i given
cat |sed "s/~/'~'/g" at input level and i used "'":input_column:"'"
out put is coming correctly
but
1. when i open the input file first getting blank popup window and then able to view the data
2. job is aborted status and getting this error=> Filter status 65,280
please let me know any suggetions.
thanks
savis wrote:Hi,
If this is the only column available in input or if this is the only column having ~ characters coming in input , use
cat |sed "s/~/'~'/g"
in the filter command(Sequential file)
Input: abc~cdfg~tx
Output:abc'~'cdfg'~'tx
If you want the output data as 'abc'~'cdfg'~'tx', then use a stage variable say quote with value "'" and in transformer use
quote:<Input_col_name>:quote
where quote is the stage variable having value as " ' ".
Note:
[We can also include the option quote=single]
[I even tried the option squote, but if there is single quote within the field then this command adds a \ before each single quote.
i.e) input sdsdsd output : 'sdsdsd'
input sd'sd'sd output : 'sd\'sd\'sd'
]
Gurus,
Please correct me if i am wrong.
Thanks,
Savis
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: