Filtering Columnar Data

Gregory Lypny gregory.lypny at videotron.ca
Mon Jul 16 17:04:26 EDT 2007


Thanks for your replies, Chris, Josh, Mark, and Richard,

You've confirmed what I suspected: that it will be tricky to get the  
filter command to do this.  This is especially true in my case  
because the data field has 56 columns by default but individual rows  
may have data appended later, and so may grow beyond 56.

I think I'll do what I used to do before the filter command was  
around, and that is to repeat an itemOffset over the data.  I tested  
the function below, which is much like Josh's, and it filters more  
than 300 lines in 1 tick; the same code as a message handler rather  
than a function takes 5 ticks; and the filter command on the same  
data takes 39 ticks.

Thanks once again,

	Gregory


function filterByColumn theData,columnNum, theSearchString
   -- This function filters tab-delimited data by column
   if columnNum is an integer
   then
     set the itemDelimiter to tab
     repeat for each line thisLine in theData
       if item columnNum of thisLine is theSearchString
       then
         put thisLine & return after filteredData
       end if
     end repeat
     delete the last character of filteredData
     return filteredData
   else
     return "The column number must be an integer."
   end if
end filterByColumn




More information about the use-livecode mailing list