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
delimiter of 2 characters in file
Moderators: chulett, rschirm, roy
Re: delimiter of 2 characters in file
Hi Ericevanmaas 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
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
There is one way of doing it.. but is a round about way.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
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
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"
Let's pretend your delimiter is "||" and you want to replace it to "|". Your filter command will be:
sed "s/||/|/g"
Tiago
Re: delimiter of 2 characters in file
You can not specify || as delimiter.ashwin141 wrote:Hi Ericevanmaas 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
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
delimiter of 2 characters in file
Thanks alot, never tried that
Well what Tiago suggested, is a good way of doing the change in file and then processing it.
Ashwin
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
If they're both the same separator like in ||, you could use | as a separator and use every other field for the further processingevanmaas 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
Re: delimiter of 2 characters in file
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.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 something to keep in mind. Make sure your sed command works as expected in all test cases before implementing.
Brad