duplicates

Remove duplicate items from an array

ぃ、小莉子 提交于 2019-11-26 12:19:05
问题 I use the line of code below to loop through a table in my database: $items_thread = $connection -> fetch_all($sql); And if I print the array out: print_r($items_thread); I will get this: Array ( [0] => Array ( [RecipientID] => 3 [RecipientScreenname] => Tom L [RecipientFirstname] => Thomas [RecipientEmail] => info@xx.com ) [1] => Array ( [RecipientID] => 3 [RecipientScreenname] => Tom L [RecipientFirstname] => Thomas [RecipientEmail] => info@xx.com ) [2] => Array ( [RecipientID] => 1

In MySQL, can I copy one row to insert into the same table?

别说谁变了你拦得住时间么 提交于 2019-11-26 12:16:31
问题 insert into table select * from table where primarykey=1 I just want to copy one row to insert into the same table (i.e., I want to duplicate an existing row in the table) but I want to do this without having to list all the columns after the \"select\", because this table has too many columns. But when I do this, I get the error: Duplicate entry \'xxx\' for key 1 I can handle this by creating another table with the same columns as a temporary container for the record I want to copy: create

ffmpeg - remove sequentially duplicate frames

与世无争的帅哥 提交于 2019-11-26 12:07:03
问题 Is there any way to detect duplicate frames within the video using ffmpeg . I tried -vf flag with select=gt(scene\\,0.xxx) for scene change. But, it did not work for my case. 回答1: Use the mpdecimate filter, whose purpose is to "Drop frames that do not differ greatly from the previous frame in order to reduce frame rate." This will generate a console readout showing which frames the filter thinks are duplicates. ffmpeg -i input.mp4 -vf mpdecimate -loglevel debug -f null - To generate a video

How do I remove duplicate items from an array in Perl?

送分小仙女□ 提交于 2019-11-26 12:03:51
I have an array in Perl: my @my_array = ("one","two","three","two","three"); How do I remove the duplicates from the array? Greg Hewgill You can do something like this as demonstrated in perlfaq4 : sub uniq { my %seen; grep !$seen{$_}++, @_; } my @array = qw(one two three two three); my @filtered = uniq(@array); print "@filtered\n"; Outputs: one two three If you want to use a module, try the uniq function from List::MoreUtils The Perl documentation comes with a nice collection of FAQs. Your question is frequently asked: % perldoc -q duplicate The answer, copy and pasted from the output of the

How to remove duplicates based on a key in Mongodb?

坚强是说给别人听的谎言 提交于 2019-11-26 11:57:31
问题 I have a collection in MongoDB where there are around (~3 million records). My sample record would look like, { \"_id\" = ObjectId(\"50731xxxxxxxxxxxxxxxxxxxx\"), \"source_references\" : [ \"_id\" : ObjectId(\"5045xxxxxxxxxxxxxx\"), \"name\" : \"xxx\", \"key\" : 123 ] } I am having a lot of duplicate records in the collection having same source_references.key . (By Duplicate I mean, source_references.key not the _id ). I want to remove duplicate records based on source_references.key , I\'m

Removing elements that have consecutive duplicates

社会主义新天地 提交于 2019-11-26 11:50:19
I was curios about the question: Eliminate consecutive duplicates of list elements , and how it should be implemented in Python. What I came up with is this: list = [1,1,1,1,1,1,2,3,4,4,5,1,2] i = 0 while i < len(list)-1: if list[i] == list[i+1]: del list[i] else: i = i+1 Output: [1, 2, 3, 4, 5, 1, 2] Which I guess is ok. So I got curious, and wanted to see if I could delete the elements that had consecutive duplicates and get this output: [2, 3, 5, 1, 2] For that I did this: list = [1,1,1,1,1,1,2,3,4,4,5,1,2] i = 0 dupe = False while i < len(list)-1: if list[i] == list[i+1]: del list[i] dupe

PHP: Check for duplicate values in a multidimensional array

↘锁芯ラ 提交于 2019-11-26 11:33:32
问题 I have this issue with multidimensional arrays. Given the following multidimensional array: Array( [0] => Array(\"a\", \"b\", \"c\") [1] => Array(\"x\", \"y\", \"z\") [2] => Array(\"a\", \"b\", \"c\") [3] => Array(\"a\", \"b\", \"c\") [4] => Array(\"a\", \"x\", \"z\") ) I want to check its values and find duplicates (i.e. keys 0, 2 and 3) leaving just one key - value pair deleting the others, resulting in somthing like this: Array( [0] => Array(\"a\", \"b\", \"c\") [1] => Array(\"x\", \"y\",

Removing Duplicates From Array of Custom Objects Swift

穿精又带淫゛_ 提交于 2019-11-26 11:24:18
问题 I have a custom class defined as follows : class DisplayMessage : NSObject { var id : String? var partner_image : UIImage? var partner_name : String? var last_message : String? var date : NSDate? } Now I have an array myChats = [DisplayMessage]? . The id field is unique for each DisplayMessage object. I need to check my array and remove all duplicates from it, essentially ensure that all objects in the array have a unique id . I have seen some solutions using NSMutableArray and Equatable

Android Studio: Duplicate files copied in APK META-INF/DEPENDENCIES when compile

馋奶兔 提交于 2019-11-26 11:06:35
问题 I exported my project from Eclipse and imported to Android Studio using the instructions in this link: http://developer.android.com/sdk/installing/migrate.html When I build, I have an error: Duplicate files copied in APK META-INF/DEPENDENCIES After searching, I found a solution: add packagingOptions { exclude \'META-INF/DEPENDENCIES\' } into build.gradle . And it works! But I don\'t understand why I had this error and why I\'ve had to apply that fix. Can anybody explain? 回答1: In Android

MySQL delete duplicate records but keep latest

纵饮孤独 提交于 2019-11-26 10:25:56
问题 I have unique id and email fields. Emails get duplicated. I only want to keep one Email address of all the duplicates but with the latest id (the last inserted record). How can I achieve this? 回答1: Imagine your table test contains the following data: select id, email from test; ID EMAIL ---------------------- -------------------- 1 aaa 2 bbb 3 ccc 4 bbb 5 ddd 6 eee 7 aaa 8 aaa 9 eee So, we need to find all repeated emails and delete all of them, but the latest id. In this case, aaa , bbb and