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
29
votes
2 answers

How do I create a multiple column unique constraint in SQL Server

I have a table that contains, for example, two fields that I want to make unique within the database. For example: create table Subscriber ( ID int not null, DataSetId int not null, Email nvarchar(100) not null, ... ) The ID column…
Neilski
  • 4,385
  • 5
  • 41
  • 74
29
votes
5 answers

Getting a compile time error CS0579: Duplicate 'AssemblyFileVersionAttribute' attribute

I recently added some copyright information to a set of C# projects (dlls) via the Properties->Application->Assembly Information button. I have several such projects in a single solution. Upon compilation I get error message of the type: error…
user236520
28
votes
8 answers

Oracle Equivalent to MySQL INSERT IGNORE?

I need to update a query so that it checks that a duplicate entry does not exist before insertion. In MySQL I can just use INSERT IGNORE so that if a duplicate record is found it just skips the insert, but I can't seem to find an equivalent option…
Bad Programmer
  • 3,642
  • 13
  • 46
  • 53
28
votes
20 answers

How to find duplicate elements in array using for loop in Python?

I have a list with duplicate elements: list_a=[1,2,3,5,6,7,5,2] tmp=[] for i in list_a: if tmp.__contains__(i): print i else: tmp.append(i) I have used the above code to find the duplicate elements in the list_a. I…
Beginner
  • 379
  • 1
  • 4
  • 14
27
votes
5 answers

How to remove duplicate entries from an array?

In the following example, "Algorithms in C++" is present twice. The $unset modifier can remove a particular field but how to remove an entry from a field? { "_id" : ObjectId("4f6cd3c47156522f4f45b26f"), "favorites" : { "books" : [ …
P K
  • 9,972
  • 12
  • 53
  • 99
27
votes
5 answers

Duplicate TCP traffic with a proxy

I need to send (duplicate) traffic from one machine (port) and to two different machines (ports). I need to take care of TCP session as well. In the beginnig I used em-proxy, but it seems to me that the overhead is quite large (it goes over 50% of…
ufffffff
  • 271
  • 1
  • 3
  • 3
27
votes
5 answers

Is there a short way to check uniqueness of values without using 'if' and multiple 'and's?

I am writing some code and I need to compare some values. The point is that none of the variables should have the same value as another. For example: a=1 b=2 c=3 if a != b and b != c and a != c: #do something Now, it is easy to see that in a…
Bunny Davis
  • 407
  • 4
  • 9
27
votes
9 answers

Pythonic way of removing reversed duplicates in list

I have a list of pairs: [0, 1], [0, 4], [1, 0], [1, 4], [4, 0], [4, 1] and I want to remove any duplicates where [a,b] == [b,a] So we end up with just [0, 1], [0, 4], [1, 4] I can do an inner & outer loop checking for the reverse pair and append…
Mr Mystery Guest
  • 1,464
  • 1
  • 18
  • 47
27
votes
2 answers

Drop duplicates using pandas groupby

In the dataframe below, I would like to eliminate the duplicate cid values so the output from df.groupby('date').cid.size() matches the output from df.groupby('date').cid.nunique(). I have looked at this post but it does not seem to have a solid…
Collective Action
  • 7,607
  • 15
  • 45
  • 60
27
votes
2 answers

Using machine learning to de-duplicate data

I have the following problem and was thinking I could use machine learning but I'm not completely certain it will work for my use case. I have a data set of around a hundred million records containing customer data including names, addresses,…
26
votes
15 answers

Deleting duplicate lines in a file using Java

As part of a project I'm working on, I'd like to clean up a file I generate of duplicate line entries. These duplicates often won't occur near each other, however. I came up with a method of doing so in Java (which basically made a copy of the file,…
Monster
  • 1,573
  • 6
  • 23
  • 35
26
votes
6 answers

How to check for duplicates in mysql table over multiple columns

I have a table of baseball players(all 1000 or so), with fields: mysql> describe person; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra …
cfrederich
  • 1,790
  • 6
  • 26
  • 35
26
votes
4 answers

How can I duplicate an object to another object, without changing the base object in Kotlin?

this is my code: var header1: Record? = null var header2: Record? = null header2 = header1 header2.name = "new_name" but header1.name changes too!
SadeQ digitALLife
  • 1,403
  • 4
  • 16
  • 22
26
votes
6 answers

Remove duplicate values from an array of objects in javascript

i have an array of objects like this: arr = [ {label: Alex, value: Ninja}, {label: Bill, value: Op}, {label: Cill, value: iopop} ] This array is composed when my react component is rendered. The i user Array.prototype.unshift for adding…
RamAlx
  • 6,976
  • 23
  • 58
  • 106
26
votes
3 answers

How can I duplicate a div onclick event?

I want a div to be duplicated when a button is clicked. I though something like this; but it's not working. Can anyone help me? HTML
duplicate EVERYTHING INSIDE THIS DIV
JAVASCRIPT function duplicate() { var div =…
Opoe
  • 1,337
  • 8
  • 30
  • 56