House of Fusion
Home of the ColdFusion Community
Hostmysite ColdFusion Hosting

Search cf-talk

July 20, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition

For ColdFusion hosting try HostMySite.com.
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

delete duplicates

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morchella
05/21/2008 03:10 PM

i have some duplicates in a list i need to delete but am not getting it once again. <cfloop From = "1" To = "#ListLen(getAce.specs_partnum)#" index = "Counter">     <cfoutput group="specs_partnum">     <cfset acccL = #ListGetAt(getAce.specs_partnum,Counter)#>     <cfset acccL = ListSort("#acccL#","text", "ASC")>     #acccL#         </cfoutput></cfloop> <br /><br /> </cfoutput> spits out: Cable Management 9969593 9969593 9969599 9969599 9969594 9969594 9969600 9969600 9969599 9969599 9969601 9969601 9969600 9969600 9969928 9969928 9969601 9969601 9969927 9969927 9969928 9969928 9969597 9969597 9969927 9969927 9969736 9969736 9969597 9969597 9969595 9969595 9969736 9969736 9969598 9969598 9970253 9970254 9970255 9970256 9970263 9970264 9970265 9970266 9970271 9970271 9970271 9970271 thanks guys.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Qasim Rasheed
05/21/2008 03:16 PM

I am sure there are few udf on cflib.org that can be used. Have you looked there? HTH On Wed, May 21, 2008 at 3:08 PM, morchella <morchella.deliciosa@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Gerald Guido
05/21/2008 03:45 PM

http://www.cflib.org/udf.cfm?id=532 /** * Case-sensitive function for removing duplicate entries in a list. * @param list      The list to be modified. * @return Returns a list. */     function ListDeleteDuplicates(list) {       var i = 1;       var delimiter = ',';       var returnValue = '';       if(ArrayLen(arguments) GTE 2)         delimiter = arguments[2];           list = ListToArray(list, delimiter);           for(i = 1; i LTE ArrayLen(list); i = i + 1)         if(NOT ListFind(returnValue, list[i], delimiter))         returnValue = ListAppend(returnValue, list[i], delimiter);       return returnValue; }     /**      * Case-INsensitive function for removing duplicate entries in a list.      * @param list      List to be modified.      * @return Returns a list.      */     function ListDeleteDuplicatesNoCase(list)     {       var i = 1;       var delimiter = ',';       var returnValue = '';       if(ArrayLen(arguments) GTE 2)         delimiter = arguments[2];           list = ListToArray(list, delimiter);       for(i = 1; i LTE ArrayLen(list); i = i + 1)       if(NOT ListFindNoCase(returnValue, list[i], delimiter))       returnValue = ListAppend(returnValue, list[i], delimiter);       return returnValue;     } On Wed, May 21, 2008 at 3:08 PM, morchella <morchella.deliciosa@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morchella
05/21/2008 03:58 PM

all that seems to do is to remove the commas? <cfoutput query="getAce" group="title"> #title# x<br /> <cfloop From = "1" To = "#ListLen(getAce.specs_partnum)#" index = "Counter">     <cfoutput group="specs_partnum">     <cfset acccL = #ListGetAt(getAce.specs_partnum,Counter)#>     <cfset acccL = '#acccL#,'>     #ListDeleteDuplicates(acccL)#         </cfoutput></cfloop> <br /><br /> </cfoutput> Cable Management x 9969593, 9969593, 9969599, 9969599, 9969594, 9969594, 9969600, 9969600, 9969599, 9969599, 9969601, 9969601, 9969600, 9969600, 9969928, 9969928, 9969601, 9969601, 9969927, 9969927, 9969928, 9969928, 9969597, 9969597, 9969927, 9969927, 9969736, 9969736, 9969597, 9969597, 9969595, 9969595, 9969736, 9969736, 9969598, 9969598, 9970253, 9970254, 9970255, 9970256, 9970263, 9970264, 9970265, 9970266, 9970271, 9970271, 9970271, 9970271, Cable Management x 9969593 9969593 9969599 9969599 9969594 9969594 9969600 9969600 9969599 9969599 9969601 9969601 9969600 9969600 9969928 9969928 9969601 9969601 9969927 9969927 9969928 9969928 9969597 9969597 9969927 9969927 9969736 9969736 9969597 9969597 9969595 9969595 9969736 9969736 9969598 9969598 9970253 9970254 9970255 9970256 9970263 9970264 9970265 9970266 9970271 9970271 9970271 9970271

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Gerald Guido
05/21/2008 05:13 PM

You have to remove the dupes before you loop over the list On Wed, May 21, 2008 at 3:57 PM, morchella <morchella.deliciosa@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bobby Hartsfield
05/21/2008 05:16 PM

An easy way to delete duplicates form a list is to loop the list into a structure using the list item as the key then use structKeyList() to get the cleaned list back out I don't know what your initial list looks like but here is an example with a space delimited list... <cfset theList = "9969593 9969593 9969599 9969599 9969594 9969594 9969600 9969600 9969599 9969599" /> <cfset uniqueListItems = structNew() /> <cfloop list="#theList#" delimiters=" " index="i">   <cfset uniqueListItems[i] = i /> </cfloop> <cfset cleanedList = structKeyList(uniqueListItems) /> .:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com http://cf4em.com all that seems to do is to remove the commas? <cfoutput query="getAce" group="title"> #title# x<br /> <cfloop From = "1" To = "#ListLen(getAce.specs_partnum)#" index = "Counter">     <cfoutput group="specs_partnum">     <cfset acccL = #ListGetAt(getAce.specs_partnum,Counter)#>     <cfset acccL = '#acccL#,'>     #ListDeleteDuplicates(acccL)#         </cfoutput></cfloop> <br /><br /> </cfoutput> Cable Management x 9969593, 9969593, 9969599, 9969599, 9969594, 9969594, 9969600, 9969600, 9969599, 9969599, 9969601, 9969601, 9969600, 9969600, 9969928, 9969928, 9969601, 9969601, 9969927, 9969927, 9969928, 9969928, 9969597, 9969597, 9969927, 9969927, 9969736, 9969736, 9969597, 9969597, 9969595, 9969595, 9969736, 9969736, 9969598, 9969598, 9970253, 9970254, 9970255, 9970256, 9970263, 9970264, 9970265, 9970266, 9970271, 9970271, 9970271, 9970271, Cable Management x 9969593 9969593 9969599 9969599 9969594 9969594 9969600 9969600 9969599 9969599 9969601 9969601 9969600 9969600 9969928 9969928 9969601 9969601 9969927 9969927 9969928 9969928 9969597 9969597 9969927 9969927 9969736 9969736 9969597 9969597 9969595 9969595 9969736 9969736 9969598 9969598 9970253 9970254 9970255 9970256 9970263 9970264 9970265 9970266 9970271 9970271 9970271 9970271

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morchella
05/21/2008 06:00 PM

thanks guys. will try that in the morning. such a beautiful day!

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morchella
05/22/2008 10:04 AM

http://63.144.103.199/products/partNumsTab3.cfm?n1ID=5&n2ID=43&n3ID=133 ok i am not getting the results i am expecting. i took the spaces out of the db.. but Cable Management still shows multiples. tried adding a ',' to the cfset so when the list loops it makes it one list. bbut its not removing duplicates.. any other ideas? Thanks! -m <cfquery name="getAce" datasource="xxx"> SELECT DISTINCT TOP 100 PERCENT title, specs_partnum, aId FROM   dbo.VIEWtempAsc WHERE     (aId IN (#aList#)) ORDER BY title </cfquery> <cfoutput query="getAce" group="title"> #title# - aId <cfoutput>#aId# </cfoutput><br /> <cfoutput><cfset theList = "#getAce.specs_partnum#," /></cfoutput> <cfset uniqueListItems = structNew() /> <cfloop list="#theList#" delimiters="," index="i">    <cfset uniqueListItems[i] = i /> </cfloop> <cfset cleanedList = structKeyList(uniqueListItems) /> <strong>theList</strong>: <cfoutput><strong>aId: #aId#</strong> #theList#</cfoutput><br /> <strong>cleanedList</strong>: <cfoutput>#cleanedList#</cfoutput><br /> <br /> <br /> </cfoutput><br /><br /> db looks like     28    Cable Management _ 600 Suited 7035 700/800 Alone 9969593,9969594,9969599,9969600,9969601,9969928,9969927,9969597,9969736,9970253,9970263,9970271     175    Cable Management _ 600 Suited 9005 700/800 Alone 9969593,9969594,9969599,9969600,9969601,9969928,9969927,9969597,9969736,9970254,9970264,9970271     176    Cable Management _ 700 Suited 7035 9969599,9969600,9969601,9969928,9969927,9969597,9969736,9969595,9969598,9970255,9970265,9970271     177    Cable Management _ 700 Suited 9005 9969599,9969600,9969601,9969928,9969927,9969597,9969736,9969595,9969598,9970256,9970266,9970271


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists