FAQ Database Discussion Community


Compare 2 seperate csv files and write difference to a new csv file - Python 2.7

python,python-2.7,csv,compare
I am trying to compare two csv files in python and save the difference to a third csv file in python 2.7. import csv f1 = open ("olddata/file1.csv") oldFile1 = csv.reader(f1) oldList1 = [] for row in oldFile1: oldList1.append(row) f2 = open ("newdata/file2.csv") oldFile2 = csv.reader(f2) oldList2 = [] for...

Check if a string contains a specific sequence of characters in Ruby

ruby,string,compare
I'm trying to check if a string contains a specific sequence of characters. More precisely, I need to verify if my string has these characters: A00[a-zA-Z] So, I have a fixed part "A00" followed by one letter [a-zA-Z]. I have to identify if my "filename" string contains this sequence filename...

How to compare string to String Array in C#?

c#,compare,user-agent,string-comparison
I have an string; String uA = "Mozilla/5.0 (iPad; CPU OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 Twitter for iPhone"; String[] a= {"iphone","ipad","ipod"}; It must return ipad because ipad is in the first match ipad at the string. In other case String uA = "Mozilla/5.0 (iPhone/iPad;...

Echo each key value from array if second array key equals

php,arrays,function,compare,exists
I have two arrays: $choices = array ( [model] => 3D Modeling / BIM [edb] => Engineering & Design-Build [gse] => Green & Sustainable Energy [ipd] => Integrated Project Design [lc] => Lean Construction [mt] => Material Supply [ecs] => Electrical Construction & Service [fps] => Fire Protection Services [hms]...

Is There a Practical Encryption Algorithm Which Maintains Comparability

encryption,compare,comparator
Is there a secure encryption algorithm, which is practical and maintains comparability? For example, if you have strings A, B, and C and A < B < C then if ran through the encryption algorithm it and the resulting values are compared then enc(A) < enc(B) < enc(C). I specifically...

Scala set element uniqueness: What to implement for comparison of user defined classes?

scala,set,compare,unique
I am trying to find this information in the Scala documentation but it looks like it is not there. In the case of Java this was dependent of the Set implementation that was used, AFAIK. In some cases the method to implement was equals, in the case of a HashSet...

Compare strings without being case-sensitive

javascript,web,compare,case-sensitive
I have problem with a variable I made (it's a string) in JavaScript. It will be prompt from the user and then with the switch I will check if it is true or not. Then when I input it upper case it will say it is identified as a another...

How to compare lists of objects with 3 or more variables(fields) in Java

java,list,collections,compare
I have 3 fields for defining a unique object, e.g.: region, name, platform which are string values. A list of such objects has to be compared with another list of such objects. I was thinking to create an object for that such as Class myObject{ private String region; private String...

Compare one string among multiple values in another string [closed]

java,regex,string,split,compare
I have 2 string as following. In first_string="B" and in second_string="A,B,C,D,E". How do i compare first_string against individual value of second_string?...

Comparing words in two textbox to find difference?

arrays,vb.net,compare
I have 2 TextBoxes. I want to compare all the words of Textbox1 with Textbox2 Let say if the second word in Textbox1 is "me" while second word in Textbox 2 is "him" it will highlight the word "him" on Textbox 2 and "me" on Textbox1. Example : Box 1...

Compare 2 csv files and output different rows to a 3rd CSV file using Python 2.7

python,python-2.7,csv,compare
I am trying to compare two csv files and find the rows that are different using python 2.7. The rows are considered different when all columns are not the same. The files will be the same format with all the same columns and will be in this format. oldfile.csv ID...

Using std::string.compare() won't work

c++,compare,stdstring
i have a little problem with the following code: std::string compare = "data_END"; while ((!(temp.compare(compare) == 0)) && std::getline(file, temp)) { std::size_t pos = temp.find(' '); std::string name = temp.substr(0,pos); std::string number = temp.substr(pos); .... So, there is a point when in the file there is a line called "data_END"....

Compare dates from given array and two date ranges swift

swift,cocoa-touch,xcode6,compare,nsdate
Hi i have a problem scenario with date comparison with given date range the scenario is as follows: i have an array containing data: var filter1Date = [String]() filter1Date[Wed, 06 May 2015 03:44:19 GMT, Wed, 06 May 2015 03:36:27 GMT, Wed, 06 May 2015 02:56:51 GMT, Wed, 06 May 2015...

Compare Datatype in C#

c#,compare
I'd like to compare the data types of two classes and return bool values. The problem is my method doesn't compare values inside class of a class Here is the code: public static class Compare { public static bool PublicInstancePropertiesEqual<T>(this T self, T to, params string[] ignore) where T :...

C# - Getting List reference index

linq,list,object,reference,compare
I have a List> List<List<Byte>> bytes = new List<List<Byte>>() { new List<Byte> {1, 1, 2, 3, 4}, // index 0 is original new List<Byte> {0, 0, 2, 4, 1}, new List<Byte> {1, 2, 2, 1, 1}, new List<Byte> {1, 0, 2, 2, 2} }; and the first List is original....

Compare 2 arrays and list the differences - Swift

arrays,swift,boolean,compare
I was wondering how one would go about comparing 2 boolean arrays and listing the non matching booleans. I have written up a simple example of 2 arrays. let array1 = [true, false, true, false] let array2 = [true, true, true, true] How would I compare array1 & array2 and...

Compare values of two vectors

r,vector,compare
I have two vectors: a <- c(23,43,54) x <- c(1,543,65,89) I would like to have a vector y of dimension 4 - (dim(x)) which indicates how many values of the vector a are upper than each coefficient of the vector x. Is there a function that does this task?...

Compare strings for equality

c#,string,compare,string-comparison
I want to compare a collection of strings and return the the equal parts until a not equal part occurs. (and remove traling whitespace). example: List<string> strList = new List<string> { "string xyz stop", "string abc stop", "string qrt stop" }; string result = GetEqualName(strList); // This should return "string"...

python compare and replace strings in txt file with filenames

python,list,replace,compare,filenames
I have a file data.txt and a sounds folder with mp3 music files. data.txt contains a list of filenames.mp3 (in random order) from the sounds folder and from other folders. I've converted the mp3 files in the sounds folder to wav, and I want to replace the filenames.mp3 in the...

if compare doesn't work in php

php,if-statement,compare
I have a problem with a comparation. I execute this code after execute nmap and saving the pid in the database: include("classes/database.php"); //conection to database $selectActual = "SELECT * from InfActual"; $resultActual = $conn->query($selectActual); if ($resultActual->num_rows > 0) { while ($rowActual = $resultActual->fetch_assoc()) { echo "pid in DB: " ....

Compare images and remove duplicates

image,compare,imagemagick,png
I have two folders with images, they're all PNGs. One folder is a copy of the other with some images changed and some added. The filenames are the same but the image contents may be different. Other attributes like time stamps are completely random, unfortunately. I want in the newer...

Groovy - compare two JSON objects (same structure) and return ArrayList containing differences

json,groovy,compare
I have two JSON objects of the same structure - an original and one which I want to compare it to. There is only one level of information (i.e nothing has any children). I want to compare the two and remember which fields, if any, were different by storing the...

java recursion test if arraylist are equal

java,recursion,arraylist,boolean,compare
I have some code that I would like to make more efficient by recursion. Trouble is I don't know where to start. The code compares two arraylists a and b to see if they are equal. Assume the sizes of both arrays are equal. The code is public boolean isEqual(A...

Compare 2 sheets with different headers

excel,vba,excel-vba,compare
I have 2 different files which have different headers, for example: OldfileHeaders | NewFileheaders ID | Test ID Date | New date and so on. I am trying to compare the data in both sheets and see if they match. The rows of data may be in different order and...

How I can compare two Directories in Powershell and move the items then older x days?

powershell,recursion,compare,move,get-childitem
hi i want to compare two objects in Powershell. the objects are directories. For example: $folderA = gci $source -Recurse $folderB = gci $destination -Recurse $diff = Compare-Object -ReferenceObject $folderA -DifferenceObject $folderB -PassThru | Where-Object {$_.SlideIndicator -eq "<="} The first Problem is if folderB dont have elements then the object...

comparing each element in a string with another string at the same position

python,string,loops,python-3.x,compare
i want to compare a student's answer to the model answer. the student undertakes a test of multiple choice questions. there is a total of 5 questions and each question has 3 multiple choices. the student chooses the following choices for all questions: "12231". e.g: for Q(1): student picks option...

SQL - I need to see how many users are associated with a specific set of ids

sql,list,compare
I'm trying to identify a list of users that all have the same set of IDs from another table. I have users 1, 2, 3, and 4, all that can have multiple IDs from the list A, B, C, and D. I need to see how many users from list...

Date comparison from VARCHAR column value

php,mysql,compare,innodb,varchar
I have a SQL table where one of the columns 'creator' is a VARCHAR data type. That column stores values like this one: Mike Jones|05-17-2015 1:21 pm consisting of the person that created the record, the date and time it was created. I need to use the date portion of...

Compare two sets of Ranges and MsgBox amount and value of common cell values

excel-vba,compare,range,msgbox
I have a problem with this code and I'm not able to resolve it. I have two sets of ranges; Range("C14:C19") and Range("E14:E19") each containing 6 Numbers generated randomly (I already coded the random selection). My goal is to, after generating the Numbers, compare both Ranges. If both Ranges contain...

Compare two data frames, column-order-independent, to get non-duplicated rows [duplicate]

r,data.frame,compare
This question already has an answer here: pair-wise duplicate removal from dataframe 3 answers I want to compare two data frames and check if there are duplicated rows. We assume that the order of columns doesn't matter so if df1 looks like that: V2 V3 71 78 90 13...

Weird error comparing ints [duplicate]

java,android,integer,int,compare
This question already has an answer here: Why does 128==128 return false but 127==127 return true in this code? 4 answers I have a weird weird weird weird error, first of all here the class which give me the error public class SpeciePesci { public static final SpeciePesce[] specie...

Compare a function with another function

php,function,compare
I made a function which is contain an include file, Can I compare this function with other function ? e.g. in a.php <?php $a = "this is file"; ?> in b.php <?php $b = "this is file"; ?> in function.php <?php function a(){ include("a.php"); } function b(){ include ("b.php"); }...

“Comparison method violates its general contract!”, everything seems OK

java,collections,compare,comparator,comparable
I am aware of the compare rules in Java (and in general) as described here. I have an ArrayList of Strings. Each String represent a Texas Hold'em Poker Hand ignoring the suit. Each String is exactly 13 characters long. Each String consists of digits only whose sum is 7. For...

AngularJS Filter two select inputs with values less than or equal to value

javascript,angularjs,select,filter,compare
I would like to setup two select inputs so that the combined value of either select input should be less than or equal to a specific value. Newbie to the AngularJS world so I may have overlooked something. I assume a filter but it might be ng-change that I should...

Compare two files and append the values, leave the mismatches as such in the output file

awk,compare,match,mismatch
I'm trying to match two files,file1.txt(50,000 lines), file2.txt(55,000 lines). I want to campare file2 to file 1 extract the values of column 2 and 3 and leave the mismatches as such. Output file must contain all the ids from file2 i.e., it should have 55000 lines. Note: All the ids...

Compare two files with first column matching text and 2nd column of first file > than 2nd column value of 2nd file

awk,compare,multiple-columns
Looking for an awk one liner: I have two files each with two columns I need to print records where the first column match in both files and where the second file value column is > than the first file value column. file1 AAAA 322 BBBB 322 DDDD 200 file2...

Checking equality of three or more Strings in Java [duplicate]

java,string,if-statement,compare
This question already has an answer here: Is there clean syntax for checking if multiple variables all have the same value? 7 answers I know this is a very basic question, but I am always trying to find ways to make my code a clean and concise as possible....

How to make a function that compares strings?

string,function,swift,compare
I want to make a function which compares strings. I don't want to use equal operators (==), I want it worked only with Swift language. First I made a function which takes 2 strings, and returns bool type. then I looped these strings with for in syntax. And want to...

How do I pass a variable number of arrays in a hash to the List::Compare perl module?

perl,list,hash,compare
I know this question has been asked before here (compare multiple hashes for common keys merge values). As far as I can tell, it went unanswered. If you answer, please include an example that uses the List::Compare->new() constructor. List::Compare has the ability to accept multiple arrays as input. However, there...

Comparing Strings and changing the color of a row

javascript,arrays,string,table,compare
I am trying to create a method that compares the strings of two elements that are in different arrays. All the the strings are in rows on a table. If those two strings are equal then the row should be green. Otherwise the row should be red. I have the...

Double compare in JavaScript looks weird [duplicate]

javascript,boolean,compare,boolean-expression
This question already has an answer here: chaining double equals == returns false 3 answers Let's var a = "first", b = "second", c = "first";. Expression a == c returns true, (of course!); a == c is true too. Then why does a == a == c return...

Compare date and datetime

php,sql,datetime,compare
I want to compare a datetime from sql and the todays date. The datetime in sql is for example 2015/05/09 12:00:00 and the current date is 2015/05/09. I want to compare these things if they are equal, but for the whole day so the time is a problem. I have...

Unable to replicate : “Comparison method violates its general contract!”

java,sorting,exception,compare,comparator
I receive the following error: "Comparison method violates its general contract!" when using the following comparator, however I am unable to replicate the exception using jUnit. I'd like to know what caused this issue and how to replicate it. There are examples of others having the same problem but not...

IF == not working for lists in python. No idea what I am doing wrong. A print() of the data reveals they are equal…what am I missing?

python,list,if-statement,compare
So, here is my code. It is meant to take answers from a user. Store their answers in a list (answerlist. Compare their answers to a list made from the lines of a answers.txt file. The problem is, altough they ARE the same (looking at a print() output), the script...

Comparing data frames in R

r,compare
I am really new to R and stackoverflow; apologies in advance for issues with my question. I have two data frames data.frame 1: Product.ID Description Wholesale.Price Prod1 Desc1 1.45 Prod Desc2 1.27 Prod3 Desc 3.62 Prod4 Desc4 2.15 Prod5 Desc5 2.87 Prod12 Desc6 2.53 Prod7 Desc7 2.20 Prod8 Desc8 2.60...

Comparable and (MyClass)null

java,nullpointerexception,null,compare,comparable
Say I have public class MyClass implements Comparable<MyClass> { public int compareTo(MyClass mc) { //<implementation ommited>... } } The docs for Comparable say that "The natural ordering for a class C is said to be consistent with equals if and only if e1.compareTo(e2) == 0 has the same boolean value...

MySQL doesn't exclude query results from other query

mysql,compare,exclude,notin
I have an experiment DB, and try to get all the participants that wish to be recontacted except for the ones that participated in one specific experiment. The query works, except that it only doesn't include the participants that took part only in this experiment, but does include participants that...

C++ String comparison not working as intended

c++,string,if-statement,compare
I am trying to compare two strings for a trivia program, one entered by a user and the other accessed from a node. The comparison is within an IF statement and always returns false. Below is the code used for this function. Both variables userAnswer and answer are of the...

Perl comparing two hashes

perl,hash,compare
I am a beginner with Perl, and am trying to write a script to compare the two hashes and print the values in the first hash that are not found in the second. Although I know the script should be very simple, I am not sure why mine is not...

Python - Using a created list as a parameter

python,list,loops,if-statement,compare
When I run my code it tells me: Type Error: unorderable types: str() < float(). I can't figure out why it won't let me compare these two numbers. The list I am using is defined, and the numbers in it have been redefined as floats, so I'm not sure what...

How to compare two expressions with maxima?

compare,maxima
I have two complicated mathematical expressions. How can I compare them, to find if they express the same using Maxima?

Split comma separated list, sort and compare - output the difference - KSH

unix,compare,ksh,string-comparison
I'm working on a problem in KSH, and need to take two comma separated lists and compare them, then output the differences. Example input 1: apple, banana Example input 2: apple, banana, kiwi Output: kiwi I assume I will need to put the lists into arrays and compare each string...

Is there a variable type for comparators?

c#,variables,compare
Is there a variable type (something like string, int, or bool) for comparators? (==, !=, <=, >=, >, <) And if not, how does C# use them? I can use int integerVariable = 0; but is there something I can use to do comp comparatorVariable = ==; ?...

comparing two dates. Equal isn't working as well

sql,date,ms-access,compare,equals
I've got trouble with comparing two dates: There is short datetime field in database, recorded by Microsoft Access 2002-2003 data extension (#yyyy/mm/dd#). When I tried to compare via operators "greater than" and "less than" it works fine, but when I replaced with the operator "equal" it's giving me an empty...

Comparison between unsigned int and int without using cast operator

c,int,compare,type-conversion,unsigned-integer
everyone I looked aroud there exist an topic about my question. I could not find . unsigned int x = 5; int y = -3; if(y<x) func1(); else func2(); func2 is called . But i want to call func1 . I know that, I must use cast operator by using...

Compare code from the files of two directores [closed]

php,ftp,compare,comparison
I have several files & folders in domain.com and a working copy in: domain.com/beta I want to compare the code of all files (php files) in the beta folder with the ones in the main folder and just view the files in which the codes do not match. I've googled...

Sort an Array of ArrayList in java

java,arrays,sorting,arraylist,compare
I want to sort an Array of ArrayList by the first int of the ArrayLists elements. I have tried to override the compare method of the Comparator class but it throws: Exception in thread "main" java.lang.NullPointerException at BikeGA$1.compare(BikeGA.java:515) at BikeGA$1.compare(BikeGA.java:1) at java.util.TimSort.countRunAndMakeAscending(TimSort.java:351) at java.util.TimSort.sort(TimSort.java:230) at java.util.Arrays.sort(Arrays.java:1438) at BikeGA.main(BikeGA.java:512) The code...

php compare array of string to string [closed]

php,arrays,compare
Lets say I have string $string = "12315"; I want to compare this array and want the result as this : $arr = [ "123", //should be true "115", //should be true "111", //false "132", //true "1512" //true "5531" //false ] The array value shouldn't have each count number greater...

Comparing Strings using a buffer

java,string,compare,buffer
I have a problem when comparing Strings. Let's say for example I have a buffer for a string that holds 1024 bits. If I fill that buffer up with the String "Hello", then the buffer would contain "Hello" + the remaining amount of bytes. If I create another String assigned...

Compare 2 tables and add missing records to the first, taking into account year/months

sql,compare,records,missing-data
I have 2 tables, one with codes and budgets called FACT_QUANTITY_TMP and the other is a tree with all possible codes called C_DS_BD_AP_A. All codes that exist are in this C_DS_BD_AP_A table, yet not all are in FACT_QUANTITY_TMP. Only those with budget get added by the ERP. We need all...

Abstract class using IComparer

c#,compare,abstract-class,icomparer
I want to create and abstract class A that implements IComparer so that I can implement different forms of comparing in the subclasses and later on do: A sortBy = new B(); A sortBy2 = new C(); I'm new in C# and I don't quite get how to do that....

TSQL update value with subquery

sql-server,tsql,sql-update,compare
I have 2 tables and want to compare them and modify tableA (set NameMod = 1) if it has different rows. To compare tables I use: select Id, Name from tableB except select Id, Name from tableA And then I want to modify tableA: update tableA Set NameMod = 1...

SQL Compare rows

mysql,sql,sql-server,compare
Okay here is the situation: I the following data in a table. PAIR_NO NO NO2 3 5678EFGH 1234ABCD 4 1111BBBB 0000AAAA 1 1234ABCD 5678EFGH 2 0000AAAA 1111BBBB The constraints are if no = no2 in another row skip that row. So in this sample data the only rows that would...

Efficient comparison of small integer vectors

c,integer,compare,bit-manipulation,string-comparison
I have small vectors. Each of them is made of 10 integers which are between 0 and 15. This means that every element in a vector can be written using 4 bits. Hence I can concatenate my vector elements and store the whole vector in a single long type (in...

Comparator not letting me compare T values

java,generics,tree,compare,comparator
Intellij idea is giving me this error in class internalNode when trying to compare two T values: compare(capture,capture) cannot be applied to (T,T). I can't understand why. I've already changed the parametrized type to T and it still shows me the message but instead of capture just T. Any help...

Comparing R0 with R1 using assembly (Keil)

assembly,compare,8051,keil
I have two values stored in R0 and R1. I am comparing the two as follows: MOV R3, #(R0 XOR R1) CJNE R3,#0,NOT_EQUAL Apparently it is not possible to use the XOR OPERATOR this way. Is there another way to compare R0 with R1 and check is they are equal...

python compare difference between two lists

python,list,compare
I have two lists like this: newList = ( (1546, 'John'), (8794, 'Michael'), (892416, 'Dave'), (456789, 'Lucy'), ) oldList = ( (1546, 'John'), (8794, 'Michael'), (892416, 'Dave'), (246456, 'Alexander') ) I would like to have a function comparing both lists. It would be something like this: def compare(new, old): print('Alexander...

WPF Listbox Collection custom sort

wpf,sorting,listbox,compare,collectionview
I have a listbox DropPrice MyPrice Price1 Price2 I want to sort it like this Price1 Price2 DropPrice MyPrice I mean, if there's an item that starts with the sequence "price", it gets priority, else the smallest string should get the priority. My source code: var lcv = (ListCollectionView)(CollectionViewSource.GetDefaultView(_itemsSource)); var...

Java double comparing vs. String comparing

java,compare,double
I came across some old legacy code as the below: s1 = Double.toString(dbVal1); s2 = Double.toString(dbVal2); if (s1.compareTo(s2)!=0) { return false; } return true; where dbVal1 and dbVal2 are both double values. I found this while profiling, and the toString method calls take a fair amount of CPU time. Is...

Comparing char* with char

c,char,compare
I am working on a program where I get the name of a file from the input in a command line. I need to check if the input is a given character say "-" and work with the file according to this result, but I am not quite sure how...

Java Compare 2 integers with equals or ==?

java,int,compare,equals
i am very very new to Java and i would like to know how can i compare 2 integers? I know == gets the job done.. but what about equals? Can this compare 2 integers? (when i say integers i mean "int" not "Integer"). My code is: import java.lang.*; import...

Compare large numbers

python,compare
For a txt which has the size of files in a dir, I am trying to print the lines where the file appears with less size from a threshold (20Mb) . My code looks like comp = 200000000 with open("files.txt") as f: for line in f: parts = line.split( )...

R - Compare two data frames of different length for same values in two columns

r,compare
This is a question about how to compare several columns of two different data frames with varying length. I have two data frames (data from receiver1 (rec1) and receiver2 (rec2)) of different lengths containing positions for 4 different ships: rec1 <- data.frame(name = sample (c("Nina", "Doug", "Alli", "Steve"), 20, replace...

Compare two strings in vba excel [Resolved]

excel,vba,excel-vba,compare,string-comparison
I need to compare each cell of the column "Chef" to each cell of the column "nom", so that I can find the right "matricule" and store it in "matt", I have tried this this VBA code: Sub compare() Dim p As Integer Dim q As Integer Dim Nom As...

using qsort in C

c,compare,qsort
I have a problem compiling a program that uses 'qsort' I have to sort a dynamic array of pointers to a struct (called Element) when I try to compile the program I get the following error: "error: passing argument 4 of 'qsort' from incompatible pointer type..." my compare function (for...

WPF Comparing values from diferent buttons

c#,wpf,button,compare
Let's say that I'd like to make an app that has got 3 buttons, one button makes some math (and the result is X), another one makes some math (and the result is Y), and the last button says "Compare", and compares X and Y. How is it possible to...

Finding partial matches on strings in R

regex,r,string,compare
I have a very large database with names like this: names <- c("William Gates", "Bill Gates", "Gates, William H. III", "Gates, William III", "William H Gates", "William H. Gates", "Carlos Slim Helu & family", "Carlos Slim Helu", "Carlos Slim & Family", "Carlos Slim") which I would like to 'clean up'...

Why are these objects not equal?

javascript,json,compare
I am trying to write a test in JavaScript using Mocha and Chai. At the end of the test, I want to compare 2 JavaScript objects, these should be equal. The output I get from the test is the following: { publication: { publication_id: 'pubFetch1', title: 'Publication Fetcher', person_id: 'uploader',...

Four-Gamete-Test R

r,compare,dna-sequence
I have (will have) data, that looks like the following: Individual Nuk Name Position Individual.1 Nuk.1 Name.1 Position.1 Ind 1 A Locus_1988 23 Ind 1 A Locus_3333 15 Ind 2 A Locus_1988 23 Ind 2 G Locus_3333 15 Ind 3 G Locus_1988 23 Ind 3 A Locus_3333 15 Ind 4...

Synchronize local SQLite database with central database

android,performance,sqlite,compare
We are developing an Android App based on a product that already has a website. As a result, when launching the Android app it may happen that a lot of things differ between the local SQLite database and our central database. What is the fastest way to synchronize the Android...

NsArray ContainsObject is not working with Custom NsObject Class

ios,objective-c,compare,nsarray,nsobject
I am checking if my one of the array consist the Nsobject which i have created custom way. i am using ContainsObject method.my problem is that contains object not working ever.even though i have same object in array its not returning the true value. if([self.arrSelectedInterest containsObject:interest_ent]) i am also attaching...

Find & count occurrences of certain words matching text/string/paragraph (most efficient way)

php,regex,algorithm,compare,pattern-matching
I have a Paragraph that I have to parse for different keywords. For example, Paragraph: "I want to make a change in the world. Want to make it a better place to live. Peace, Love and Harmony. It is all life is all about. We can make our world a...

R - Comparing values in a vector to a single value (Using the apply family)

r,vector,compare,value
I Have this database (shortened) > head(testDB,25) Civilite Age Enfants Region Recence Frequence_visite_site Mailing_Clic 1 Mlle 18 Non Nord 5 5 Oui 2 Mlle 18 Non Sud 3 5 Oui 3 Mlle 18 Non Nord 3 8 Non 4 Mlle 18 Non Nord 7 6 Non 5 Mlle 18 Non...

Compare Two Hebrew Strings Alphabetically

vb.net,compare,hebrew
I know that I can use the String.Compare(StringA, StringB) to compare two strings and see which one comes first alphabetically However, I tried this with two Hebrew strings, and it doesn't compare alphabetically. Is there another way to do this, or do I have to change something with the encoding?...

Why does this code always print “not matched”?

c,compare,popen,strcmp
#include <stdio.h> int main(int argc, char const *argv[]) { FILE *ls = popen("tmp.sh", "r"); char char_array[256]; while (fgets(char_array, sizeof(char_array), ls) != 0) { //NOP } char *ptr_somechar = &char_array[0]; char *pointer = "high"; if (strcmp(pointer, ptr_somechar) == 0) { printf("%s\n", "match"); } else { printf("%s\n", "not matched"); } pclose(ls); return...

Creating and comparing two sets of cards [closed]

c++,arrays,compare
How would I go about creating a hand of cards based on the code below and then comparing them without changing too much of what I have already? I am thinking about how to go about this and am thinking of creating an array for each hand and then populating...

How to check if two times overlap in PHP?

php,time,compare,unix-timestamp
So I'm trying to figure out how to check if two times overlap using PHP and a MySQL database. This is the function I'm using to check if they are overlapping: function testRange($start_time1,$end_time1,$start_time2,$end_time2) { return ($end_time1 < $start_time2) ? false : ($start_time1 > $start_time2) && ($start_time1 > $end_time2) ? false...

Comparing calendar objects

java,calendar,compare
I'm having some trouble with comparing 2 calendar objects. Here's my code: String date = "06/19/2015"; Calendar c = Calendar.getInstance(); String days="", months="", years=""; Scanner sc = new Scanner(date); sc.useDelimiter("/"); while(sc.hasNext()){ months = sc.next(); days = sc.next(); years = sc.next(); } int day = Integer.parseInt(days); int month = Integer.parseInt(months); int...

Compare data from a string array in c

c,arrays,string,compare
I'm trying to compare something that i read with fgets with the words from the first column of the array, but I can't get it, I thing it could be the \0 at the end of each string but I can't get the comparison works #include <stdio.h> #include <string.h> #define...

How to read and compare strings in Java? [closed]

java,string,compare,statements
I have been trying to compare a string to another, or a string to a statement, but I can't find where the mistake is. I tried with the == but it didnt work, then i changed to .equals() static Scanner scan = new Scanner(System.in); public static void main(String[] args) {...

Comparing variable to string in Bash

string,bash,compare
I've tried the suggestion at How do I compare two string variables in an 'if' statement in Bash? but it's not working for me. I have if [ "$line" == "HTTP/1.1 405 Method Not Allowed" ] then <do whatever I need here> else <do something else> fi No matter what,...

I need to be able to compare entries of a file - Java

java,file,compare
`import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Dokimi { private static String line; public static void main (String[] args) throws IOException { int x = 0; BufferedReader br = new BufferedReader(new FileReader("src/film.txt")); line = br.readLine(); String[] filmline = new String [1000]; while (line != null) { line = br.readLine();...

Python pandas: Efficiently compare rows of a dataframe?

python,pandas,compare
I have dataframe 'dfm' : match group adamant 86 adamant 86 adamant bild 86 360works 94 360works 94 where the 'group' column is the same, I want to compare the content of the 'match' column two by two and add the comparison results in another column 'result'. For instance expected...

Order LINQ query elements by a collection of numbers

.net,vb.net,linq,compare,compareto
This is a partially defined function that I'm using to retrieve the specified lines of a textfile, by passing the index of the lines I want: Public Shared Function GetLines(ByVal sourceFilepath As String, ByVal lineNumbers As IEnumerable(Of Integer)) As IEnumerable(Of String) Return File.ReadAllLines(sourceFilepath, encoding). Select(Function(line As String, index As Integer)...

Two tables with similar columns but different primary keys

mysql,table,join,compare,multiple-databases
I have two tables from two different databases, and both contain lastName and firstName columns. I need to create JOINa relationship between the two. The lastName columns match about 80% of the time, while the firstName columns match only about 20% of the time. And each table has totally different...

Find match and similarity in two of files R language

r,data.frame,compare,similarity
I have two of large files, the contents of the files looks like: df1 df2 dput of df1 structure(list(X00.00.location.long. = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,...

Comparison between vectors in matlab

matlab,compare
if i have A=[3 4 5 6] and B=[6 5 4] then i want to compare each value in A with all values in B, if this value is greater then increase counter with 1 and if this value is equal then increase another counter with 1

How can I compare two source code files/ ast trees?

parsing,go,compare,abstract-syntax-tree
I'm generating some source code using the templates package( is there a better method? )and part of the testing I need to check if the output matches the expected source code. I tried a string comparison but it fails due the extra spaces / new lines generated by the templates...

HashMap Keys and Value comparison [closed]

java,dictionary,compare,key-value
I'm comparing HashMap value against the keys and replace if key is larger. The purpose is to update Finger Table of Chord System simulation. I have HashMap data: Key 0 with Values: [1,2,4,8,16] Key 3 with Values: [4,5,7,11,19] Key 7 with Values: [8,9,11,15,23] The desired outcome is such that for...

Comparing Generics that are comparable in Java

java,generics,compare,comparable
I have a Generic Binary Tree that will add objects lessThan or equalTo to the left, and objects greater than to the right. My problem is with the comparing the Generics, I know the data value will be a object-wrapped primitive or a String, so they are comparable. But, I...