Filtering Columnar Data

Josh Mellicker josh at dvcreators.net
Mon Jul 16 12:43:37 EDT 2007


filter tmpData with "*" & tab & myNumber & tab & "*"
  will work, except it will return lines that have a "9" in ANY  
column...


The best way I have found to do this is a generic handler that will  
retrieve lines from any 2-dimensional field of data based on the  
header value and search data.

That is, if you want to know who likes pizza, ask

put FindSomeLines(the long id of fld "favorites", "favFood", "pizza")  
into tPizzaLovers


here's the field:

name   favColor   favFood
Greg   blue   pizza
Ken   green   burgers
Rich   chrome   pizza


and the handler:

function FindSomeLines pFldName, pHeader, pSearchData
  put fld pFldName into tData
  put offset(pHeader, line 1 of tData) into tColNum
  set the itemdel to tab -- (if your field is tab-delimited)

  repeat for each line tLine in tData
   if item tColNum of tLine = pSearchData
    put tLine & cr after tFoundLines
   end if
end repeat

delete the last char of tFoundLines

return tFoundLines
end FindSomeLines


This is not tested, but should be close I hope!





On Jul 16, 2007, at 9:18 AM, Chris Sheffield wrote:

> Gregory,
>
> Try this and see if it works.
>
> 	filter tmpData with "*" & tab & myNumber & tab & "*"
>
> There shouldn't be any need to include the preceding or trailing  
> tabs, except for the ones directly surrounding the number.
>
> Chris
>
>
> On Jul 16, 2007, at 9:58 AM, Gregory Lypny wrote:
>
>> Hello Everyone,
>>
>> I'm struggling with the filter command.  I have tab-delimited data  
>> in a field, where each row has at least 56 columns.  I want to  
>> filter the data based on a chosen number in that fourth column,  
>> for example, to return all lines that have a 9 there.  The fourth  
>> column only contains a number from 1 to 10.  The following handler  
>> works most of the time.  I put three wild card expressions, lone  
>> asterisks separated by tabs, to make sure nothing is being picked  
>> up in the first three columns.  The tab and asterisk (and it could  
>> be just an *) following myNumber says that it doesn't matter what  
>> is in the columns after the fourth.
>>
>> 	put fld "Data" of this card into tmpData
>> 	filter tmpData with "*" & tab & "*" & tab & "*" & tab & myNumber  
>> & tab & "*"
>>
>> The trouble is, the first three wild card expressions are  
>> interpreted by Revolution to include tab characters, which means  
>> that I'm not necessarily filtering the fourth column!  If a 9  
>> appears by itself in column 58, then the filter command will pick  
>> it up.  Sigh.
>>
>> I also tried the following, but I don't think I have the regular  
>> expression syntax right.
>>
>>    filter it with "[A-Z0-9]" & tab & "[0-9]" & tab & "[A-Z]" & tab  
>> & myNumber & tab & "*"
>>
>> I know that my first column always contains five words, two of  
>> which are numbers.  I wasn't sure how to represent the four spaces  
>> between the words.  The second column is always a seven-digit  
>> number.  The third contains first and last names, which will  
>> contain at least two words.  This turns up empty.
>>
>> Any advice would be most appreciated.  If I can't get the RegEx  
>> working for me, I know I can resort to a repeat loop and pull out  
>> all lines with myNumber in the fourth item.
>>
>> Regards,
>>
>> 	Gregory
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> ------------------------------------------
> Chris Sheffield
> Read Naturally
> The Fluency Company
> http://www.readnaturally.com
> ------------------------------------------
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list