Help how to extract first field in a string (csv file)
Moderators: chulett, rschirm, roy
Help how to extract first field in a string (csv file)
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
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
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
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>
<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>
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.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
That will be
Maveric, Thanks for pointing it out.
Code: Select all
Field(Field(Input.String,',',1),'=',2)
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>
<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>
The FIELD function does not exist in a modify stage; only in the transform stage.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
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
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
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Re: Help how to extract first field in a string (csv file)
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
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