The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Find string value in column

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
LC_ Posted - 05/21/2015 : 07:23:31 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2015 SR1
Operating System: Win 7

Hi, I need to find a string in a column of string data. I tried to use vfind, but if I search for a string it will always return me a vector with all the row numbers in the column. Example is below (extract from actual function).

Thanks in advance

function name_conversion (string refName)
{
//finds row corresponding to refName
dataset found_rows;
vfind ix:=col(1) value:=refName$ ox:=found_rows;
//if refName$ is a string, vfind will return all the rows in col(1) and the correct row if refName$ is numeric
return 0;
}

string str_test1$ = name_conversion("blablabla")$;
4   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 05/27/2015 : 4:26:46 PM
It is unfortunate that Origin does not have a basic string search function for a column, so I have written it as follows:

function int sfind(string str, range cc)
{
	int nRows = cc.nRows;
	dataset tmp = data(1, nRows);
	string str1$=lookup(str$, cc, tmp)$;
	int nn = %(str1$);
	return nn;
}


To use it, you have to define a range variable, like

range aa=col(1);
v1=sfind("abc",aa);
v1=;


CP
LC_ Posted - 05/26/2015 : 06:48:16 AM
Hi Amanda! Thanks very much for your answer. Using wxt for this purpose was not very obvious to me.
AmandaLu Posted - 05/26/2015 : 05:21:18 AM
Hi LC,

Castiel is right. vfind is used to find numeric values. To find string, please try wxt:

http://www.originlab.com/doc/X-Function/ref/wxt

Thanks,
Amanda
OriginLab Technical Service
Castiel Posted - 05/21/2015 : 09:06:06 AM
Documentation says "value" must be a double precision floating point number....vfind is not for strings.

©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000