Jump to content
UBot Underground

Recommended Posts

ok so I have this massive table with 8 variable/columns and 300+ rows. Im trying to compare row 1 col 1 to row 2 col 1 if they are the same then delete a row.. Not really sure how to get started on this..having difficulty with wrapping my head around the incr of it all..

Any tips or examples?

Link to post
Share on other sites

Hi,

 

Did you get what you need for this?

 

If not this is what I was thinking.

 

I set it to look through column 1. With this variable #srchtabcolumn. You may need to adjust it.

I coded in a choice as to which row to delete on a match. You can delete the row you are looking for or the row you found the match on. Set in this variable #removetabitem. Valid values are found or lookingfor.

 

Sample code:

clear list(%tablist)
add list to list(%tablist, $list from file("C:\\downloads\\tab.csv"), "Delete", "Global")
clear table(&tabsearch)
create table from file("C:\\downloads\\tab.csv", &tabsearch)
set(#removetabitem, "found", "Global")
set(#srchtabcolumn, 1, "Global")
set(#finishedtable, "false", "Global")
set(#tabposition, 0, "Global")
loop while($comparison(#finishedtable, "=", "false")) {
if($both($comparison(#tabposition, ">", 0), $comparison(#tabposition, "<", $table total rows(&tabsearch)))) {
 then {
	 set(#tvm1, $table cell(&tabsearch, $subtract(#tabposition, 1), #srchtabcolumn), "Global")
	 set(#tabsrchposition, #tabposition, "Global")
	 set(#tabupdated, "false", "Global")
	 loop($table total rows(&tabsearch)) {
		 if($comparison(#tabsrchposition, "<", $table total rows(&tabsearch))) {
			 then {
				 set(#tv1, $table cell(&tabsearch, #tabsrchposition, #srchtabcolumn), "Global")
			 }
			 else {
			 }
		 }
		 if($comparison(#tv1, "=", #tvm1)) {
			 then {
				 loop(0) {
					 alert("in if tvm1={#tvm1}=tv1={#tv1}=tabpos={#tabposition}=tabsrchposition={#tabsrchposition}=tabupdated={#tabupdated}=end")
				 }
				 set(#removeposition, "novalue", "Global")
				 if($comparison(#removetabitem, "=", "lookingfor")) {
					 then {
						 set(#removeposition, $subtract(#tabposition, 1), "Global")
					 }
					 else {
					 }
				 }
				 if($comparison(#removetabitem, "=", "found")) {
					 then {
						 set(#removeposition, #tabsrchposition, "Global")
					 }
					 else {
					 }
				 }
				 if($comparison(#removeposition, "!=", "novalue")) {
					 then {
						 remove from list(%tablist, #removeposition)
						 save to file("C:\\downloads\\tab-cleanup.csv", %tablist)
						 set(#tabupdated, "true", "Global")
						 set(#tv1, "removed={#tv1}=from={#removeposition}=end", "Global")
					 }
					 else {
					 }
				 }
			 }
			 else {
			 }
		 }
		 increment(#tabsrchposition)
	 }
	 if($comparison(#tabupdated, "=", "true")) {
		 then {
			 clear table(&tabsearch)
			 create table from file("C:\\downloads\\tab-cleanup.csv", &tabsearch)
			 set(#tabposition, 0, "Global")
			 set(#tv1, "xx", "Global")
			 set(#tabupdated, "false", "Global")
		 }
		 else {
		 }
	 }
 }
 else {
	 if($comparison(#tabposition, ">=", $subtract($table total rows(&tabsearch), 1))) {
		 then {
			 set(#finishedtable, "true", "Global")
		 }
		 else {
		 }
	 }
 }
}
increment(#tabposition)
}

 

sample-table-cleanup-002.ubot

 

Kevin

Link to post
Share on other sites

Thanks I ran this through and it gives me some good ideas but with a large list it really uses a lot of memory, had it up to 6 gig on a 60 k file and it takes quite some time to process... Im playing with it thanks for the head start

Link to post
Share on other sites

I found that by running this it was much faster although less effective more loops gives the final results needed

 

define cleanactivelist {
set(#emaillistROW, 0, "Global")
set(#testemailsROW, 0, "Global")
loop($table total rows(&activebuslisting)) {
set(#testemail, $table cell(&activebuslisting, #emaillistROW, 4), "Global")
if($comparison(#testemail, "=", $nothing)) {
then {
}
else {
set table cell(&testemails, #testemailsROW, 0, #testemail)
set table cell(&testemails, #testemailsROW, 1, $table cell(&activebuslisting, #emaillistROW, 1))
set table cell(&testemails, #testemailsROW, 2, $table cell(&activebuslisting, #emaillistROW, 2))
set table cell(&testemails, #testemailsROW, 3, $table cell(&activebuslisting, #emaillistROW, 3))
increment(#testemailsROW)
}
}
increment(#emaillistROW)
}
}

 

I then ran further checks to verify the results from rows 2,3,4 , it all runs almost instantly this way

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...