duplicates

Remove duplicates in NSdictionary

旧巷老猫 提交于 2019-12-02 06:22:25
Is there a way to remove duplicate (key-value) pairs from NSDictionary ? EDIT: My description was misleading, I have duplicate pairs e.g. key1-value1 key1-value1 key2-value2 key1-value1 etc.. Vladimir reversing key-value is not good idea because not all values can be keys. You can do it with: // dict is original dictionary, newDict new dictionary withot duplicates. NSMutableDictionary * newDict = [NSMutableDictionary dictionaryWithCapacity:[dict count]]; for(id item in [dict allValues]){ NSArray * keys = [dict allKeysForObject:item]; [newDict setObject:item forKey:[keys objectAtIndex:0]]; }

“INSERT INTO .. ON DUPLICATE KEY UPDATE” Only inserts new entries rather than replace?

五迷三道 提交于 2019-12-02 06:19:43
I have a table, say table1, which has 3 columns: id, number, and name. id is auto_incremented. I want to achieve an sql statement which inserts entries into a table, but if the row already exists, then ignore it. However, Every time I run: INSERT INTO table1( number, name) VALUES(num, name) ON DUPLICATE KEY UPDATE number = VALUES(number), name = VALUES(name) It seems to ignore rows with matching number and name values and appends entries to the end of the table no matter what. Is there anything I can do to prevent this? I have a feeling it has something to do with having the auto_incrementing

R - find all unique values among subsets of a data frame

落花浮王杯 提交于 2019-12-02 05:55:14
问题 I have a data frame with two columns. The first column defines subsets of the data. I want to find all values in the second column that only appear in one subset in the first column. For example, from: df=data.frame( data_subsets=rep(LETTERS[1:2],each=5), data_values=c(1,2,3,4,5,2,3,4,6,7)) data_subsets data_values A 1 A 2 A 3 A 4 A 5 B 2 B 3 B 4 B 6 B 7 I would want to extract the following data frame. data_subsets data_values A 1 A 5 B 6 B 7 I have been playing around with duplicated but I

excel duplicate values pairs in multiple column

ⅰ亾dé卋堺 提交于 2019-12-02 05:45:14
问题 Is there a way to find duplicate pairs in multiple columns in Excel? For instance, column1 column2 Smith Jones <-- duplicate pair Smith Johnson Jones Smith <-- duplicate pair Jones Walter 回答1: The way I would do it would be as follows: (Assuming your data begins in cell A1 & B1) In C1, put in the formula: =A1&"|"&B1 In D1, put in the formula: =B1&"|"&A1 In E1, put in the formula: =MATCH(C1,$D$1:$D$500,0) Drag all these down for your dataset (and change the $500 in your final formula if

Creating manual threads - but getting duplicate threads

ⅰ亾dé卋堺 提交于 2019-12-02 05:11:35
ISSUE: Getting duplicate items, i.e more threads are getting created than the array size... Hi Folks, I am creating thread in the loop for each element of array. The real use is that the of sending a batch of messages using amazon ses. the messages are stored in the messageamazonRequestBatch and the loop runs through the batch and sends the messages. HERE IS THE CODE: Thread thrdSendEmail; try { string amazonMessageID = string.Empty; List<Thread> lstThread = new List<Thread>(); foreach (int n in arrMessageid) { thrdSendEmail = new Thread(() => { try { amazonMessageID = SendSimpleEmail_Part2

How to add only unique values from CSV into ComboBox?

a 夏天 提交于 2019-12-02 05:08:35
I want to read a csv File and put words " Jakarta " and " Bandung " in a combobox. Here's the input id,from, 1,Jakarta 2,Jakarta 5,Jakarta 6,Jakarta 10,Bandung 11,Bandung 12,Bandung I managed to get the words and put it in the combobox, but as you can see, the text file itself contains a lot word " Jakarta " and " Bandung " while i want to show both only once in the combobox. Here's my temporary code, which works for now but inefficient and probably can't be used if the word has more variety public String location; private void formWindowOpened(java.awt.event.WindowEvent evt) { String csvFile

Finding strings with duplicate letters inside

断了今生、忘了曾经 提交于 2019-12-02 04:56:24
问题 Can somebody help me with this little task? What I need is a stored procedure that can find duplicate letters (in a row) in a string from a table "a" and after that make a new table "b" with just the id of the string that has a duplicate letter. Something like this: Table A ID Name 1 Matt 2 Daave 3 Toom 4 Mike 5 Eddie And from that table I can see that Daave , Toom , Eddie have duplicate letters in a row and I would like to make a new table and list their ID's only. Something like: Table B ID

Select multiple field duplicates from MySQL Database

做~自己de王妃 提交于 2019-12-02 04:24:07
I've got an old forum which contains threads with duplicate first posts (perhaps differing replies). I want to delete all but one of these threads (leaving the thread with the highest view count). I have the following SQL query to help identify duplicate threads, but I can't find a way for it to list only duplicates with the lowest value for the xf_thread.view_count column: SELECT t.thread_id, MIN(t.view_count) FROM xf_thread t INNER JOIN xf_post p ON p.thread_id = t.thread_id WHERE t.first_post_id = p.post_id GROUP BY t.title, t.username, p.message HAVING COUNT(t.title) > 1 AND COUNT(t

R - subset column based on condition on duplicate rows

旧巷老猫 提交于 2019-12-02 03:59:54
I have a dataframe with an id column that is repeated, with site counts. I want to know how I can remove the duplicates ID records only when Site_Count record is more than 0. Generate DF: DF <- data.frame( 'ID' = sample(100:300, 100, replace=T), 'Site_count' = sample(0:1, 100, replace=T) ) My attempt at the subset: subset(DF[!duplicated(DF$ID),], site_count > 0) But in this case it will remove all 0 site counts - I want to subset to only remove the record when there is a duplicate record with more than 0 site count. Desirable results would look something like this (notice there site IDs with 0

MySQL - How to join two tables without duplicates?

醉酒当歌 提交于 2019-12-02 03:57:09
I have two tables like the following hotels ------ hotelID hotelName Second table operators --------- opID opName opServices opHotelID a short explanation: In the first table I have a lot of hotels which have an increment id which is unique. The second table contains all the operators offering this hotel with additional services. The opID here is unique too but the opHotelID exists multiple times, because there can be many operators offering the hotel. Now, what I want to get is the following: I want to get the HotelName and an additional Column (called Operators) which lists all the operators