Page 1 of 1
delimiter of 2 characters in file
Posted: Wed May 17, 2006 4:52 am
by evanmaas
Hi,
I have a file that contains delimiters of 2 characters (e.g. ||).
How can I read this file because DS Designer accept only a delimiter of 1 character?
Kind Regards,
Erik
Re: delimiter of 2 characters in file
Posted: Wed May 17, 2006 5:17 am
by ashwin141
evanmaas wrote:Hi,
I have a file that contains delimiters of 2 characters (e.g. ||).
How can I read this file because DS Designer accept only a delimiter of 1 character?
Kind Regards,
Erik
Hi Eric
You mean you have records like a||b||c||123||d||
Did you try specifying || as delimiter?
Other way out is that you change the || to | in your file and then read it.
Please let us know which one works.
Regards
Ashwin
Re: delimiter of 2 characters in file
Posted: Wed May 17, 2006 5:21 am
by dprasanth
evanmaas wrote:Hi,
I have a file that contains delimiters of 2 characters (e.g. ||).
How can I read this file because DS Designer accept only a delimiter of 1 character?
Kind Regards,
Erik
There is one way of doing it.. but is a round about way.
Say you have three fields
a||b||c
Now when u define the table defn for the file, give the delimiter as |
Now u can defined the column defns as
col1
del1
col2
del2
col3
del3
So when u read this file, del1, del1,del3 will be '|'. Now you can use the fields you want.
Use a unix command
Posted: Wed May 17, 2006 5:54 am
by tiagogen
You can use a filter command: sed(unix command) to replace 2 delimiters to 1
Let's pretend your delimiter is "||" and you want to replace it to "|". Your filter command will be:
sed "s/||/|/g"
Re: delimiter of 2 characters in file
Posted: Wed May 17, 2006 6:00 am
by evanmaas
ashwin141 wrote:evanmaas wrote:Hi,
I have a file that contains delimiters of 2 characters (e.g. ||).
How can I read this file because DS Designer accept only a delimiter of 1 character?
Kind Regards,
Erik
Hi Eric
You mean you have records like a||b||c||123||d||
Did you try specifying || as delimiter?
Other way out is that you change the || to | in your file and then read it.
Please let us know which one works.
Regards
Ashwin
You can not specify || as delimiter.
delimiter of 2 characters in file
Posted: Wed May 17, 2006 6:41 am
by ashwin141
Thanks alot, never tried that
Well what Tiago suggested, is a good way of doing the change in file and then processing it.
Ashwin
Re: delimiter of 2 characters in file
Posted: Wed May 17, 2006 1:06 pm
by JeroenDmt
evanmaas wrote:Hi,
I have a file that contains delimiters of 2 characters (e.g. ||).
How can I read this file because DS Designer accept only a delimiter of 1 character?
Kind Regards,
Erik
If they're both the same separator like in ||, you could use | as a separator and use every other field for the further processing
Re: delimiter of 2 characters in file
Posted: Wed May 17, 2006 2:41 pm
by bcarlson
ashwin141 wrote:Thanks alot, never tried that
Well what Tiago suggested, is a good way of doing the change in file and then processing it.
Ashwin
Just a word of warning - be careful of null fields. What if you have 'a||b||||d' (where the c column is actually null)? The input implies 4 columns, but if all double-delimiters get converted you could end up with 'a|b|d' and have lost the actual 3rd column.
Just something to keep in mind. Make sure your sed command works as expected in all test cases before implementing.
Brad