Source language: Translate to:

List algorithms

General questions about NeoBook

Moderator: Neosoft Support

List algorithms

Postby dpayer » Tue Aug 12, 2014 9:00 am

I may simply end up using a database connection to solve some of the issues I am facing but I thought I would ask others to see how they solve this kind of issue.

I want to compare lists. Typical goals: how many elements in this list vs. that one. Which elements of this list ARE and ARE NOT in the other. With relational databases it is easy to get the 'which ARE' comparisons, less so the 'ARE NOT'.

I'm looking for the best algorithm to do these things with NB. My method now works but is slow. Example, list of approximately 2500 phone numbers copied from an Excel sheet. I get the count in NB by doing a STRPARSE using the [#13] as the delimiter. I get the element count but it takes 30-45 seconds. Then I loop through the one list and delete all instances of from that variable array from the strparse that are found in the 2nd list. This could take minutes.

There are probably plugins that could help. I'm doing a utility at work on my own license of NB but the company likely would not spring for the cost of plugins/upgrades (when I could do this laboriously in Excel - why pay more, they'd say).

Are there suggestions for a different methodology? Would RegEx be able to count instances of an element? Is this a place where NB needs help via DBPro? Viewpoints appreciated.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: List algorithms

Postby David de Argentina » Tue Aug 12, 2014 10:47 am

Hi DavidP,

If i understood well, you can:

* open each list as database using the ODBC text connector.
* fill a database (for a example, a MDB) tables, with the content of each list (or importCSV each list file)
* compare both tables using a simple "Select * from table1 left join table2 on telnumber1 = telnumber2" or something like this
* save the previous query on a new table.
* process the result table

My defaulted cent,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: List algorithms

Postby HPW » Tue Aug 12, 2014 11:39 am

Hello,

Lisp was invented for ListProcessing. So a lisp-dialect could be used for the job.
In this case I could think of using newLISP here , which has the (length ...) command for the count. And there are (intersect .. ..) and (difference .. ..) for ARE and ARE NOT.
Only a testcase with the same lists could show the performance vs. neobook.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: List algorithms

Postby Neosoft Support » Tue Aug 12, 2014 11:43 am

This will likely still suffer from some performance issues with large amounts of data, but I have used ListBoxes to compare lists of items. For example, assuming that ListBox1 and ListBox2 have been loaded* with data:

Code: Select all
.get size of each list box
ListBoxSize "ListBox1" "[LB1Size]"
ListBoxSize "ListBox2" "[LB2Size]"

.find items common to both lists
SetVar "[CommonItems]" ""
Loop "1" "[LB1Size]" "[Count]"
  ListBoxGetItem "ListBox1" "[Count]" "[Temp]"
  ListBoxFindItem "ListBox2" "[Temp]" "[Found]"
  If "[Found]" ">" "0"
    SetVar "[CommonItems]" "[CommonItems][Temp],"
  EndIf
EndLoop

.find items in list 1 missing from list 2
SetVar "[ItemsNotIn2]" ""
Loop "1" "[LB1Size]" "[Count]"
  ListBoxGetItem "ListBox1" "[Count]" "[Temp]"
  ListBoxFindItem "ListBox2" "[Temp]" "[Found]"
  If "[Found]" "=" "0"
    SetVar "[ItemsNotIn2]" "[ItemsNotIn2][Temp],"
  EndIf
EndLoop

.find items in list 2 missing from list 1
SetVar "[ItemsNotIn1]" ""
Loop "1" "[LB2Size]" "[Count]"
  ListBoxGetItem "ListBox2" "[Count]" "[Temp]"
  ListBoxFindItem "ListBox1" "[Temp]" "[Found]"
  If "[Found]" "=" "0"
    SetVar "[ItemsNotIn1]" "[ItemsNotIn1][Temp],"
  EndIf
EndLoop


*You can load a #13 delimited list into a ListBox by simply placing a variable in the ListBox's properties instead of a list of items.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: List algorithms

Postby dpayer » Tue Aug 12, 2014 1:11 pm

David / Hans Peter / Dave,

Thanks for your suggestions. Each has given me something to consider. All were useful.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest