Read a file with a delimiter as string
Moderators: chulett, rschirm, roy
Read a file with a delimiter as string
Hi,
I have a file with |& as the delimiter.
eg: abc|&cde|&fgh|&ijk
I need to extract the values based on the delimiter |&
Tried Field () function, but didn't work here.
any other idea?
Thanks
I have a file with |& as the delimiter.
eg: abc|&cde|&fgh|&ijk
I need to extract the values based on the delimiter |&
Tried Field () function, but didn't work here.
any other idea?
Thanks
That don't work, as i am reading the file entirely..
and the delimiter count is different for each line.
Here is the file looks like
HEADER|&Value1|&Value2|&Value3
Body|&Val1|&Val2|&|Val3|&Val4
Body|&Val5|&Val6|&|Val7|&Val8
Tail|&Date
I am splitting the file and writing into 3 different files (header, body, tail).
Is there any function in Transformer to extract particular field value?
and the delimiter count is different for each line.
Here is the file looks like
HEADER|&Value1|&Value2|&Value3
Body|&Val1|&Val2|&|Val3|&Val4
Body|&Val5|&Val6|&|Val7|&Val8
Tail|&Date
I am splitting the file and writing into 3 different files (header, body, tail).
Is there any function in Transformer to extract particular field value?
A minor detail you failed to mention in the original post.
I would suggest using the Field() function like you were for a single character, say the pipe as the field delimiter, and then strip the extraneous second character from the field. That or making a pass to convert those pairs to a single character, something that could be as simple as stripping one, then use Field() on the survivor.
I would suggest using the Field() function like you were for a single character, say the pipe as the field delimiter, and then strip the extraneous second character from the field. That or making a pass to convert those pairs to a single character, something that could be as simple as stripping one, then use Field() on the survivor.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
That would be a problem,if the source data have | character.
chulett wrote:A minor detail you failed to mention in the original post.
I would suggest using the Field() function like you were for a single character, say the pipe as the field delimiter, and then strip the extraneous second character from the field. That or making a pass to convert those pairs to a single character, something that could be as simple as stripping one, then use Field() on the survivor.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Change the delimiter in source with something like
and use '~' as your delimiter.
You can do the same within the job.
Code: Select all
sed 's/\|\&/~/g' yourFileName
You can do the same within the job.
-
- Participant
- Posts: 6
- Joined: Fri Jun 11, 2010 7:01 am
Re: Read a file with a delimiter as string
If you are using sequential file use:
final delimiter : none
quote: none
Delimiter : |
I hope this will help you
final delimiter : none
quote: none
Delimiter : |
I hope this will help you