Questions tagged [duplicates]

The "duplicates" tag concerns detecting and/or dealing with multiple instances of items in collections.

A duplicate is any re-occurrence of an item in a collection. This can be as simple as two identical strings in a list of strings, or multiple complex objects which are treated as the same object when compared to each other.

This tag may pertain to questions about preventing, detecting, removing, or otherwise dealing with unwanted duplicates, or adapting to safely allow duplicates.

15777 questions
38
votes
8 answers

What exception type should be thrown when trying to add duplicate items to a collection?

Following code should throw exception to prevent adding duplicate collection item. ICollection collection = new List(); public void Add(T item) { if (collection.Contain(item)) { throw new SomeExceptionType() } …
klashar
  • 2,519
  • 2
  • 28
  • 38
38
votes
12 answers

Select and display only duplicate records in MySQL

This question is pretty simple I for some reason can't get the proper result to display only the duplicate records Table : Paypal_ipn_orders id payer_email 1 susan@gmail.com 2 …
user1542036
  • 423
  • 2
  • 5
  • 9
38
votes
5 answers

Dealing with duplicate contacts due to linked cards in iOS' Address Book API

Some beta-users of my upcoming app are reporting that the list of contacts contain a lot of duplicate records. I'm using the result from ABAddressBookCopyArrayOfAllPeople as the data source for my customized table view of contacts, and it baffles me…
epologee
  • 11,229
  • 11
  • 68
  • 104
37
votes
18 answers

MySQL duplicate entry error even though there is no duplicate entry

I am using MySQL 5.1.56, MyISAM. My table looks like this: CREATE TABLE IF NOT EXISTS `my_table` ( `number` int(11) NOT NULL, `name` varchar(50) NOT NULL, `money` int(11) NOT NULL, PRIMARY KEY (`number`,`name`) ) ENGINE=MyISAM; It contains…
user1763581
  • 605
  • 1
  • 8
  • 17
36
votes
2 answers

Grouping by multiple columns to find duplicate rows pandas

I have a df id val1 val2 1 1.1 2.2 1 1.1 2.2 2 2.1 5.5 3 8.8 6.2 4 1.1 2.2 5 8.8 6.2 I want to group by val1 and val2 and get similar dataframe only with rows which has multiple…
Shubham R
  • 7,382
  • 18
  • 53
  • 119
36
votes
1 answer

SQL to select all rows with duplicate values in one column

I have a users table that has duplicate values in the employee_id column. I need to list all rows with duplicate employee_ids, along with their names. I need to see all users with a duplicate employee_id so I can de-conflict which values are valid.…
Jason
  • 754
  • 3
  • 8
  • 22
36
votes
13 answers

Android Studio - How to copy a project?

Alright, I've done some searching and seem to be coming close to the answer I'm looking for. But for fear of messing something up with my current project (I'm a first time app developer and I'm quite pleased so far... I'd like to stay that way),…
lilgodwin
  • 1,098
  • 3
  • 13
  • 26
36
votes
2 answers

Strong Name sn.exe: Failed to install key pair -- Object already exists

I have 2 different versions of the same project on my machine. One from the code trunk, and the other from a code branch. These projects use a .pfx key to enable strong naming. When I first tried to compile the trunk version of the project I get the…
ChrisG
  • 1,316
  • 1
  • 11
  • 14
36
votes
2 answers

duplicates in multiple columns

I have a data frame like so > df a b c d 1 1 2 A 1001 2 2 4 B 1002 3 3 6 B 1002 4 4 8 C 1003 5 5 10 D 1004 6 6 12 D 1004 7 7 13 E 1005 8 8 14 E 1006 I want to remove the rows where there are repeated values in column c AND column d. So in…
Davy Kavanagh
  • 4,809
  • 9
  • 35
  • 50
36
votes
7 answers

Return only duplicated entries from an array (case-insensitive)

I want to retrieve all case-insensitive duplicate entries from an array. Is this possible in PHP? array( 1 => '1233', 2 => '12334', 3 => 'Hello', 4 => 'hello', 5 => 'U' ); Desired output array: array( 1 => 'Hello', 2 =>…
coderex
  • 27,225
  • 45
  • 116
  • 170
35
votes
3 answers

Cloning a record in rails, is it possible to clone associations and deep copy?

I'm .clone -ing a record in rails... new_blerg = Blerg.find(1).clone This record has loads and loads of associations, and those associations even have associations. Is there a way to deep-copy a record and clone it so it is cloned with all of…
CafeHey
  • 5,699
  • 19
  • 82
  • 145
35
votes
4 answers

Robomongo : Exceeded memory limit for $group

I`m using a script to remove duplicates on mongo, it worked in a collection with 10 items that I used as a test but when I used for the real collection with 6 million documents, I get an error. This is the script which I ran in Robomongo (now known…
Carlos Siestrup
  • 1,031
  • 2
  • 13
  • 33
35
votes
12 answers

Java generating non-repeating random numbers

I want to create a set of random numbers without duplicates in Java. For example I have an array to store 10,000 random integers from 0 to 9999. Here is what I have so far: import java.util.Random; public class Sort{ public static void…
Fernando Martinez
  • 549
  • 1
  • 5
  • 10
35
votes
5 answers

Replacing a HashSet Java member

I have Set of that structure. I do not have duplicates but when I call: set.add(element) -> and there is already exact element I would like the old to be replaced. import java.io.*; public class WordInfo implements Serializable { File plik; …
Yoda
  • 17,363
  • 67
  • 204
  • 344
35
votes
3 answers

Is there a way to measure duplicate code?

I'm looking for a code duplication tool that is language agnostic. It's easy to find language specific code duplication tools (for Java, C, PHP, ...), but I'd like to run some code duplication analysis on a templates in a custom syntax. I don't care…