Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-30 Thread Peter Otten
Norman Khine wrote: > Here is the latest version http://pastie.org/1066582 can this be > further improved? > # get all the duplicates and clean the products table > main.execute("SELECT product_Id, url FROM %s.product WHERE url != ''" % db) > results = main.fetchall() > > d = defaultdict(set) >

Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Norman Khine
Hello, Thanks for the replies. On Thu, Jul 29, 2010 at 7:10 PM, Gregory, Matthew wrote: > Norman Khine wrote: >> basically i have two tables: >> >> id, url >> 24715L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' >> 24719L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' >> >> i

Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Gregory, Matthew
Norman Khine wrote: > basically i have two tables: > > id, url > 24715L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' > 24719L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' > > id, tid, > 1, 24715L > 2, 24719L > > so i want to first update t(2)'s tid to t(1)'s id for each d

Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Peter Otten
Norman Khine wrote: > hello, > > i have this tuple: > > http://paste.lisp.org/+2F4X > > i have this, which does what i want: > > from collections import defaultdict > > d = defaultdict(set) > for id, url in result: > d[url].add(id) > for url in sorted(d): > if len(d[url]) > 1: > print('%d --

[Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Norman Khine
hello, i have this tuple: http://paste.lisp.org/+2F4X i have this, which does what i want: from collections import defaultdict d = defaultdict(set) for id, url in result: d[url].add(id) for url in sorted(d): if len(d[url]) > 1: print('%d -- %s' % (len(d[url]), u