Filtering Columnar Data

Gregory Lypny gregory.lypny at
Mon Jul 16 16:04:26 CDT 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,


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

More information about the use-livecode mailing list