duplicates

Numbering/sequencing sets of same column values

▼魔方 西西 提交于 2019-12-18 07:23:11
问题 How to do numbering/sequencing for sets of same column values? For example: Col1 Col2 Andy 1 Chad 1 Bill 1 Andy 2 Bill 2 Bill 3 Chad 2 Bill 4 Since Andy got 2 values, I want to number it 1 and 2 in Column 2. For Bill , I want to number it 1, 2, 3 and 4 and so on. 回答1: You can accomplish this with countif and a sliding range : A B 1 val1 =COUNTIF($A$1:A1, A1) 2 valx =COUNTIF($A$1:A2, A2) and so on. The formula in column B can be dragged down / autofilled in the column. It anchors to the start

Remove duplicate words from a string

左心房为你撑大大i 提交于 2019-12-18 07:09:47
问题 I need to remove duplicate words from a string. How would I go about doing that? 回答1: If you want to remove the word "duplicates": string duplicatesRemoved = RTBstring.Replace("duplicates", ""); ;) The easy (and overly simplistic) way to remove duplicate words is to split on the space character and use LINQ's Distinct() method: string duplicatesRemoved = string.Join(" ", RTBstring.Split(' ').Distinct()); But this won't work in a useful way if you're working with actual sentences (i.e.

ANTLR duplicate a tree

给你一囗甜甜゛ 提交于 2019-12-18 05:21:38
问题 I use ANTLR to build a tree (CommonTree) like follwing (language: JAVA): Parser.prog_return r = parser.prog(); CommonTree t = (CommonTree) r.getTree(); Now, I need to pass "t" as a parameter, and make some changes without affecting the original tree. However, with Java's pointer, this could not been done, so I need to duplicate the tree. I have been search on the internet, the cloested thing I could find is the dupTree() method of ASTFactory class. Any suggestion or advises on how to achive

ANTLR duplicate a tree

回眸只為那壹抹淺笑 提交于 2019-12-18 05:21:04
问题 I use ANTLR to build a tree (CommonTree) like follwing (language: JAVA): Parser.prog_return r = parser.prog(); CommonTree t = (CommonTree) r.getTree(); Now, I need to pass "t" as a parameter, and make some changes without affecting the original tree. However, with Java's pointer, this could not been done, so I need to duplicate the tree. I have been search on the internet, the cloested thing I could find is the dupTree() method of ASTFactory class. Any suggestion or advises on how to achive

Insert statement that checks for duplicate before insert

放肆的年华 提交于 2019-12-18 05:14:08
问题 I need to make a insert but only if similar record don't exists for example: INSERT INTO requests ('user_id','subject','text','time') VALUES (56,'test','test 1234',6516516) but to check if there are same 'subject' and 'text' in another record to: not insert anything update 'time' and 'user_id' I need sql for both cases because I'm no sure at this moment what I'm going to use. Thanks in advance! 回答1: INSERT INTO requests ('user_id','subject','text','time') VALUES (56,'test','test 1234',6516516

Finding duplicate values in dictionary and print Key of the duplicate element

与世无争的帅哥 提交于 2019-12-18 04:44:11
问题 What can be the fastest way to to check the duplicate values in the dictionary and print its key? Dictionary MyDict which is having following values, Key Value 22 100 24 200 25 100 26 300 29 200 39 400 41 500 Example: key 22 and 25 have same values and i need to print that 22 and 25 have duplicate values. 回答1: It depends. If you have an ever changing dictionary and need to get that information only once, use this: MyDict.GroupBy(x => x.Value).Where(x => x.Count() > 1) However, if you have a

How to remove duplicate rows from matrix

喜夏-厌秋 提交于 2019-12-18 04:42:08
问题 I want to remove duplicate rows from a matrix. I read How can I remove duplicates in an array but keep the same order?, but this is not exactly what I want. The solution above removes duplicate values (cells) from matrix (and returns a vector), but I need to remove duplicate rows and return a matrix — the same matrix without duplicate rows. Example: a = [1,2; 3,4; 5,6; 1,2; 7,8] a = 1 2 3 4 5 6 1 2 7 8 %... ans = 1 2 3 4 5 6 7 8 The order doesn't matter. 回答1: See http://www.mathworks.com/help

How to remove duplicate rows from matrix

不问归期 提交于 2019-12-18 04:42:04
问题 I want to remove duplicate rows from a matrix. I read How can I remove duplicates in an array but keep the same order?, but this is not exactly what I want. The solution above removes duplicate values (cells) from matrix (and returns a vector), but I need to remove duplicate rows and return a matrix — the same matrix without duplicate rows. Example: a = [1,2; 3,4; 5,6; 1,2; 7,8] a = 1 2 3 4 5 6 1 2 7 8 %... ans = 1 2 3 4 5 6 7 8 The order doesn't matter. 回答1: See http://www.mathworks.com/help

Check and return duplicates array php

删除回忆录丶 提交于 2019-12-18 04:29:11
问题 I would like to check if my array has any duplicates and return the duplicated values in an array. I want this to be as efficient as possible. Example :$array = array(1,2,2,4,5) function returndup($array) should return 2 ; if array is array(1,2,1,2,5); it should return an array with 1,2 Also the initial array is always 5 positions long 回答1: this will be ~100 times faster than array_diff $dups = array(); foreach(array_count_values($arr) as $val => $c) if($c > 1) $dups[] = $val; 回答2: You can

How to do unique constraint works with NULL value in MySQL

时光怂恿深爱的人放手 提交于 2019-12-18 04:23:33
问题 I am looking for how to implement unique constraints with NULL check. MySQL shouldn't allow multiple null value. Employee: id | name ---|----- 1 | null 2 | null -> should give error during inserting 2nd row. 回答1: No, MySQL is doing the right thing, according to the SQL-99 specification. https://mariadb.com/kb/en/sql-99/constraint_type-unique-constraint/ A UNIQUE Constraint makes it impossible to COMMIT any operation that would cause the unique key to contain any non-null duplicate values.