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

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
tini
Participant
Posts: 24
Joined: Thu Jun 19, 2003 6:37 am

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

Post 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
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »


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

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

Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post 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".
Last edited by Maveric on Tue Sep 25, 2007 3:56 am, edited 1 time in total.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

That will be

Code: Select all


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

Maveric, Thanks for pointing it out.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
tini
Participant
Posts: 24
Joined: Thu Jun 19, 2003 6:37 am

Post by tini »

thank you for your quite respond.
I wil try it.
thanks
tini
tini
Participant
Posts: 24
Joined: Thu Jun 19, 2003 6:37 am

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The FIELD function does not exist in a modify stage; only in the transform stage.
tini
Participant
Posts: 24
Joined: Thu Jun 19, 2003 6:37 am

Post by tini »

ok, I don't want use transform,
but I still want to extract ABCDFGFDR123 only. Can I do it in Modify state?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

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

Post 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
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Post Reply