duplicate-removal

Remove duplicates in a list of lists based on the third item in each sublist

夙愿已清 提交于 2019-12-08 05:38:23
问题 I have a list of lists that looks like: c = [['470', '4189.0', 'asdfgw', 'fds'], ['470', '4189.0', 'qwer', 'fds'], ['470', '4189.0', 'qwer', 'dsfs fdv'] ...] c has about 30,000 interior lists. What I'd like to do is eliminate duplicates based on the 4th item on each interior list. So the list of lists above would look like: c = [['470', '4189.0', 'asdfgw', 'fds'],['470', '4189.0', 'qwer', 'dsfs fdv'] ...] Here is what I have so far: d = [] #list that will contain condensed c d.append(c[0])

Remove duplicate sublists from a list

。_饼干妹妹 提交于 2019-12-08 04:13:11
问题 If I have a list like this one: mylist = [[1,2,3], ['a', 'c'], [3,4,5],[1,2], [3,4,5], ['a', 'c'], [3,4,5], [1,2]] What is best way to remove duplicate sub-lists? Now I use this: y, s = [ ], set( ) for t in mylist: w = tuple( sorted( t ) ) if not w in s: y.append( t ) s.add( w ) It works, but I wonder if there is better way? Something more python-like? 回答1: Convert the elements to a tuple*, then convert it the whole thing to a set, then convert everything back to a list: m = [[1,2,3], ['a',

Remove duplicates in a list of lists based on the third item in each sublist

流过昼夜 提交于 2019-12-08 03:24:31
I have a list of lists that looks like: c = [['470', '4189.0', 'asdfgw', 'fds'], ['470', '4189.0', 'qwer', 'fds'], ['470', '4189.0', 'qwer', 'dsfs fdv'] ...] c has about 30,000 interior lists. What I'd like to do is eliminate duplicates based on the 4th item on each interior list. So the list of lists above would look like: c = [['470', '4189.0', 'asdfgw', 'fds'],['470', '4189.0', 'qwer', 'dsfs fdv'] ...] Here is what I have so far: d = [] #list that will contain condensed c d.append(c[0]) #append first element, so I can compare lists for bact in c: #c is my list of lists with 30,000 interior

C and doxygen - removing duplicates of variable documentation

旧巷老猫 提交于 2019-12-07 17:12:01
问题 I'm documenting my C code with doxygen. For better readability I group documentation of every .c/.h file pair (sometimes also more files) with defgroup and addtogroup (see doxygen in c: grouping of defines). The file pages look fine, but on the group/module pages all variable documentation is doubled. There are 2 entries for every variable that's declared (with extern) in the header file and defined in the .c file (in the summary as well as in the description part). Functions and everything

Clean up SQL data before unique constraint

懵懂的女人 提交于 2019-12-07 11:11:08
问题 I want to clean up some data in a table before putting in a unique constraint on two columns. CREATE TABLE test ( a integer NOT NULL, b integer NOT NULL, c integer NOT NULL, CONSTRAINT a_pk PRIMARY KEY (a) ); INSERT INTO test (a,b,c) VALUES (1,2,3) ,(2,2,3) ,(3,4,3) ,(4,4,4) ,(5,4,5) ,(6,4,4) ,(7,4,4); -- SELECT a FROM test WHERE ???? Output should be 2,6,7 I am looking for all rows after the first that have duplicated b,c EX: Rows 1,2 have (2,3) as b,c Row 1 is ok because it is the first, 2

Removing duplicate email address based on the lowest id in mysql

ε祈祈猫儿з 提交于 2019-12-07 09:38:26
问题 I have a table called emaildata consisting of 4 columns emailaddress, domainname, data and id. The emailaddress column should contain only unique entries, but there are many duplicates. The domainname and data column are not unique, and as such will contain duplicates which is fine. The id column is set to autoincrement so will contain only unique values. My question is how do I get rid of all rows that feature duplicate email addresses, keeping the one with the lowest id? There should be

PostgreSQL delete all but the oldest records

我怕爱的太早我们不能终老 提交于 2019-12-07 05:31:29
问题 I have a PostgreSQL database that has multiple entries for the objectid , on multiple devicenames , but there is a unique timestamp for each entry. The table looks something like this: address | devicename | objectid | timestamp --------+------------+---------------+------------------------------ 1.1.1.1 | device1 | vs_hub.ch1_25 | 2012-10-02 17:36:41.011629+00 1.1.1.2 | device2 | vs_hub.ch1_25 | 2012-10-02 17:48:01.755559+00 1.1.1.1 | device1 | vs_hub.ch1_25 | 2012-10-03 15:37:09.06065+00 1

How can I delete duplicates in MongoDb?

走远了吗. 提交于 2019-12-07 03:50:32
问题 I have a large collection (~2.7 million documents) in mongodb, and there are a lot of duplicates. I tried running ensureIndex({id:1}, {unique:true, dropDups:true}) on the collection. Mongo churns away at it for a while before it decides that too many dups on index build with dropDups=true . How can I add the index and get rid of the duplicates? Or the other way around, what's the best way to delete some dups so that mongo can successfully build the index? For bonus points, why is there a

Remove duplicates from a Json String in Java?

拥有回忆 提交于 2019-12-07 03:06:32
问题 I have a Json String with duplicate values: String json = "{\"Sign_In_Type\":\"Action\",\"Sign_In_Type\":\"Action\"}"; that correctly throws an exception when I try to create a JSONObject: try { JSONObject json_obj = new JSONObject(json); String type = json_obj.getString("Sign_In_Type"); } catch (JSONException e) { throw new RuntimeException(e); } Error: Exception in thread "main" java.lang.RuntimeException: org.json.JSONException: Duplicate key "Sign_In_Type" at com.campanja.app.Upload.main

MySQL insert on duplicate key; delete?

梦想与她 提交于 2019-12-06 19:34:52
问题 Is there a way of removing record on duplicate key in MySQL? Say we have a record in the database with the specific primary key and we try to add another one with the same key - ON DUPLICATE KEY UPDATE would simply update the record, but is there an option to remove record if already exists? It is for simple in/out functionality on click of a button. 回答1: It's a work-around, but it works: Create a new column and call it do_delete , or whatever, making it a tiny-int. Then do On Duplicate Key