Page 1 of 1

Help how to extract first field in a string (csv file)

Posted: Tue Sep 25, 2007 3:16 am
by tini
I have a comma delimite csv file
the data looks like
"qqxx=ABCDFGFDR123,ddc=0,ss=SS,t=test",getline,cool,testing


I want extract ABCDFGFDR123 only.
how do I do that?
could someone hlep me please.
thanks
tini

Posted: Tue Sep 25, 2007 3:25 am
by JoshGeorge

Field({InputString},{Delimiter},{Position},[{NumberOfFields}])

Filed(Input.Field,',',1)


Posted: Tue Sep 25, 2007 3:39 am
by Maveric
Josh wouldn't that give "qqxx=ABCDFGFDR123" as the output instead of "ABCDFGFDR123"? After extracting the value append it with "=". Then use field function. Something like Filed(Input.Field : "=",'=',2) might work. Otherwise do the concatenation in a stage variable and the use the stage variable in the derivation. Input.Field : "=" will be the StageVar derivation and Filed(StageVar,'=',2) will give you "ABCDFGFDR123".

Posted: Tue Sep 25, 2007 3:47 am
by JoshGeorge
That will be

Code: Select all


Field(Field(Input.String,',',1),'=',2)

Maveric, Thanks for pointing it out.

Posted: Tue Sep 25, 2007 10:50 am
by tini
thank you for your quite respond.
I wil try it.
thanks
tini

Posted: Tue Oct 23, 2007 10:47 pm
by tini
can I do this in modify state?
If I can then how is the code?

I try to learn the modify state.
thanks

Posted: Tue Oct 23, 2007 10:53 pm
by ArndW
The FIELD function does not exist in a modify stage; only in the transform stage.

Posted: Tue Oct 23, 2007 11:00 pm
by tini
ok, I don't want use transform,
but I still want to extract ABCDFGFDR123 only. Can I do it in Modify state?

Posted: Wed Oct 24, 2007 12:22 am
by ArndW
modify stage, not modify state.

You haven't specified how you are reading your file - as one big column, or separated into columns. Your functions in a modify stage are limited to the substring you have already asked about, so if the "=" sign is always in the same position you can use substrings, otherwise you should use a transform stage.

Moderator - Please move to EE/PX Forum

Re: Help how to extract first field in a string (csv file)

Posted: Thu Oct 25, 2007 10:51 am
by roy
I'm having trouble seeing version 4 with Parallel job type :!: Please update version/job type
tini wrote:I have a comma delimite csv file
the data looks like
"qqxx=ABCDFGFDR123,ddc=0,ss=SS,t=test",getline,cool,testing


I want extract ABCDFGFDR123 only.
how do I do that?
could someone hlep me please.
thanks
tini