Hello Josh,
Here's the final version of the function. Thanks to everyone for
their suggestions. I know there are other features and better error-
checking that can be added. Maybe later. It can extract roughly 75
records from 700 in 1 tick on an Intel-based iMac.
Regards,
Nice.
Once again, I suggest not hardwiring theColNum because it could
change... but you could always make a separate handler that figured
out the column number from a header row, lookup table or other
criteria, then call this handler.
On Jul 17, 2007, at 1:26 PM, 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
Hi Gregory,
You need to include all trailing tabs to make 56 columns (that would
be 55 tabs). That should work, but I experienced crashes when doing
this. You need to stress-test this feature before distributing your
software, if you plan to distribute it.
In this case, a sqLite or mySql
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
Chris Sheffield wrote:
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.
If he only wants hits in column 4, how will the above
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
woops, already found an error, this line:
put offset(pHeader, line 1 of tData) into tColNum
should be
put itemOffset(pHeader, line 1 of tData) into tColNum
(and it doesn't really need the line 1 but I like it there just for
clarity)
On Jul 16, 2007, at 9:43 AM, Josh Mellicker wrote:
This should work quickly enough for you:
filter tmpData with *tabmyNumbertab*
-- = good hits + false hits only
set the itemdel to tab
repeat for each line LNN in tmpData
if item 4 of LNN is myNumber then put LNN cr after newTempData
end repeat
-- = newTempData should be the hit list
Here's another solution...
function quickSortAndFilter theData,theItemNr,theFilter
set the itemDel to tab
sort theData by (item theItemNr of theData is not theFilter)
repeat for each line myLine in theData
if item theItemNr of myLine is theFilter then
put myLine cr after
Sorry, I forgot an essential line...
function quickSortAndFilter theData,theItemNr,theFilter
set the itemDel to tab
sort theData by (item theItemNr of theData is not theFilter)
repeat for each line myLine in theData
if item theItemNr of myLine is theFilter then
put myLine cr
cough/still doesn't work/cough
sorry
Best regards,
Mark Schonewille
--
Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http;//www.salery.com
Quickly extract data from your HyperCard stacks with DIFfersifier.
http://differsifier.economy-x-talk.com
Op
Here's another solution. Really.
function quickSortAndFilter theData,theItemNr,theFilter
set the itemDel to tab
sort lines of theData by (item theItemNr of each is not theFilter)
repeat for each line myLine in theData
if item theItemNr of myLine is theFilter then
put myLine cr
Yet another solution using SORT and complex sort criteria
---intro
1) the sort command says sort using the result of the function
2) the function returns a true/false
3) the result of the sort is that
the desired value in col 4 sorts to the top
4) the repeat loop scans each line to find
when the
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,
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
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,
Also, I would suggest finding the exact ColumnNum as part of the
handler- either from the header row, or a separate header variable.
If you don't, as the database evolves and columns are added (or
deleted), then you'll have to go back and change all your hardwired
column references... or
Thanks Josh, Mark, Jim, and Sarah,
Yep, I'll be going with a repeat loop. I posted my version just
after some of yours, where I also report that a repeat loop is seven
to eight times faster than the filter command. I'll try to
incorporate some of the features of yours into mine.
Thanks, Ken. Crystal clear.
Greg
On 10-Dec-05, at 8:52 AM, Ken Ray responded:
Message: 5
Date: Fri, 09 Dec 2005 23:06:07 -0600
From: Ken Ray [EMAIL PROTECTED]
Subject: Re: Filtering Columnar Data
To: Use Revolution List use-revolution@lists.runrev.com
Message-ID: [EMAIL PROTECTED
Hello everyone,
I use the filter command on tab-delimited text files when I want to
pick off a string in a particular column. For example, if the string
is located in the second column of a five column file, I use
filter theData with * tab searchString tab * tab *
tab * .
Gregory Lypny wrote:
Hello everyone,
I use the filter command on tab-delimited text files when I want to
pick off a string in a particular column. For example, if the string
is located in the second column of a five column file, I use
filter theData with * tab searchString tab
On 12/9/05 4:19 PM, Gregory Lypny [EMAIL PROTECTED] wrote:
Hello everyone,
I use the filter command on tab-delimited text files when I want to
pick off a string in a particular column. For example, if the string
is located in the second column of a five column file, I use
filter theData
A, thanks for the insight, Richard. The repeat for each form
of the loop control structure is faster than the filter command. A
quick test showed that I can cut my time by about 150 milliseconds
per 800 lines of data. Considering that I have some 4,000 files with
thousands of lines
Not sure I understand, Ken. Your first statement puts searchString
in the fifth column, while the second puts it in the fourth. If I
changed mine to
filter theData with * tab searchString tab *
or
filter theData with * tab searchString *
it would
On 12/9/05 10:26 PM, Gregory Lypny [EMAIL PROTECTED] wrote:
Not sure I understand, Ken. Your first statement puts searchString
in the fifth column, while the second puts it in the fourth. If I
changed mine to
filter theData with * tab searchString tab *
or
filter theData with *
26 matches
Mail list logo