Filtering Columnar Data
Josh Mellicker
josh at dvcreators.net
Mon Jul 16 19:38:48 EDT 2007
On Jul 16, 2007, at 2:04 PM, Gregory Lypny wrote:
> 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.
Wow, I thought that handler was fast, but never tested/compared it.
I wonder if sorting the lines by columnNum, then exiting on the first
non-matching line would be faster or slower?
>
> 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