FAQ Database Discussion Community


Concatenation of strings array issues in Python: Str(ArrayOfString[1])+“ ”+Str(ArrayOfString[2]) doesn't seem to work

string,python-2.7,concatenation,slice,string-length
Hi I have a problem with a python script, I don't manage to do a concatenation of 2 arrays of strings it returns- SyntaxError: can't assign to function call Here's my script: import os, sys, MySQLdb # connecting to a database db = MySQLdb.connect(host="localhost", user="MyUser", passwd="MyPassword",db="MyDB") cursor = db.cursor() cursor.execute("SELECT...

What is the usage of adding an empty string in a javascript statement

javascript,string,concatenation
I see an empty string ('' or "") used in many JavaScript statements but not sure what does it stand for. e.g. var field = current.condition_field + ''; Can someone please clarify?...

How can I convert multiple arrays into one single variable string?

php,arrays,string,concatenation
I have three arrays like this: $a = ["a1", "a2", "a3", "a4", "a5"]; $b = ["b1", "b2", "b3", "b4", "b5"]; $c = ["c1", "c2", "c3", "c4", "c5"]; I am looking for a way to convert the three arrays into a single string and save it in a variable like this:...

concatenation with multiple quotes while displaying html using PHP [duplicate]

php,html,concatenation
This question already has an answer here: How to combine two strings together? 14 answers Please assist in doing concatenation here echo"<form class='navbar-form navbar-left' role='search' method='POST' action='addr3.php'> <input type="hidden" name="id_delete" value="'.$id_r.'"> <button type='submit' class='btn btn-primary'> I am Roaming </button> </form>"; ...

String Contatenation with primitives in java

java,string,variables,concatenation,primitive
I just recently started learning Basics in Java, and was testing around initializing a string variable by concatenating primitive variables. public class Main{ public static void main(String[] args){ byte lbyte = 3; short lshort = 1; int lint = 1; long llong = 0; float lfloat = 2.0f; double ldouble...

Rust - String concatenation [duplicate]

string,concatenation,rust
This question already has an answer here: How do I concatenate strings? 1 answer I started programming with Rust this week and I am having a lot of problems understanding how Strings work. Right now, I am trying to do a simple program that prints a list of players...

Concatenating elements from two arrays of same indexes

perl,concatenation
I am facing an issue while concatenating elements of indexes from two arrays. Example: @x=(1,2,3,4); @y=(5,6,7,8); I want to concatenate $x[0]"_"$y[0] Like this: if @i=(..n), then $x[$i]"_"$y[$i] Suggest the possible solution....

appending two variables in php having `$` symbol in the appending string

php,concatenation
can I know how to create following types of string using loop. $row[$opt1val] $row[$opt2val] $row[$opt3val] $row[$opt4val] //... In general I create like this ` foreach($myArray as $someVar => $value){ $i++; ${"opt".$i."val"} = $value; } But to how to create this `$row[$opt1val] kind of strings so the string should behave as...

Click reinserts looped elements twice

javascript,jquery,loops,concatenation
My code, upon click on "produce", takes words from a text area, loops, and concatenates the way I need it. All's good, all is working. BUT if I press "Clear" and click "produce" again, my code inserts the looped words twice. Question: How can I always get the same result...

Concatenate two big numpy 2D arrays

python,arrays,numpy,concatenation
I have two big numpy 2D arrays. One shape is X1 (1877055, 1299), another is X2 (1877055, 1445). I then use X = np.hstack((X1, X2)) to concatenate the two arrays into a bigger array. However, the program doesn't run and exit with code -9. It didn't show any error message....

How to merge files within a sub-directory and perform this function on mutliple sub-directories

python,bash,unix,concatenation
I have a directory with ~2000 sub-directories and within each sub-directory there are between 2-10 txt files. I would like to open each sub-directory and merge or concatenate the contents into a single file, thus I would have 2000 directories, each with 1 txt file. I have tried to do...

Mysql Many to Many with Mapping table return one row and concatenate the values that would cause duplicate rows

php,mysql,many-to-many,concatenation
I am using mysql and have three tables one for events one for officials and a mapping table between. How would I query so that the following takes place: One single row per event Concatenate the multiple values for officials into the corresponding single event row. Tables are structures as...

Concatenate two audio files in Swift and play them

swift,audio,concatenation,avaudioplayer,wav
I try to concatenate .wav audio files in swift. Here is my code : func merge(audio1: NSURL, audio2: NSURL) { var error:NSError? var ok1 = false var ok2 = false var documentsDirectory:String = paths[0] as! String //Create AVMutableComposition Object.This object will hold our multiple AVMutableCompositionTrack. var composition = AVMutableComposition() var...

Concatenate variable argument list

java,concatenation,java-7,varargs,variableargumentlists
I want to prepend a String to a variable list of String arguments. public String myMethod(String... args) { return myOtherMethod("some string" + args); } Now, this of course will not work, because you cannot add these two types as such. How can I insert this string at the beginning of...

Concatenate a number to url everytime I click on the button?

javascript,string,numbers,concatenation,concat
How do I concatenate a number to string everytime I click on the button? If I log cConcate variable you will see that the first value is right but on subsequent clicks the url refuses to update. var tNumber = 1; var sSting = "http://www.test.com/"; var cConcate = sSting +...

Issues concatenating in Arrayfun with GPU processing. MATLAB

matlab,concatenation,gpu
I am having issues using arrayfun in MATLAB using GPU processing. I have simplified my situation below. I have 4 large matrices (video data as (x,y,t)). Ill use random for this example. A = gpuArray(rand(10,10,100)); B = gpuArray(rand(10,10,100)); C = gpuArray(rand(10,10,100)); D = gpuArray(rand(10,10,100)); I wish to take each pixel...

concatenating a uint8_t array into uint32_t array in C

c,arrays,concatenation
This might have been asked before. But I'll ask anyway. If someone could direct me to something relevant, that would also be great. So, if I have: uint8_t src[] = {34, 56, 31, 89, 11, 32, 67, 89}; Is this possible to get something like this through concatenation: uint32_t dst[]...

SAS Concatenate Multiple Variables to Create Data-Driven Macro Statements

sql,macros,sas,append,concatenation
In order to keep my process data-driven, I'm trying to concatenate multiple variables, separated by comma, in order to ultimately put them in a PROC SQL list to call in multiple macro statements that would otherwise clutter my SAS pogram. Take the following sample dataset: DATA TEST; INPUT YEAR CONDITION...

Best Practice for Including Javascript and Concatenate

javascript,module,include,concatenation,gulp
I have a medium sized project and I want to divide my fairly long javascript file into several submodules. Afterwards I want to concatenate all my js files with gulp.js and also minify them. I also would prefer not to use a watch task to concatenating my js every time...

“Merging two files” using operator “+”

c++,file,operator-overloading,concatenation
I was wondering, if it would be possible to code something like this: File1("dataOut.txt")=File2("Data1.txt")+File3("Data2.txt") I believe the thing I seek is to achieve concatenation via operator+. Correct me if I'm wrong, but I would have to overload that operator somewhere? I know it would probably be easier to just copy...

Concatenate values when greater than 0

sql,sql-server,database,concatenation
I'm needing to concatenate values from multiple columns if the value is greater than 0. Example: Video 1 Internet 0 Phone 3 Security 0 Basic 1 So the end value would be 1 Video|3 Phone|1 Basic| Is there a better way to do this than writing code like: Case When...

Concatenate string via XAML

wpf,xaml,concatenation,string.format
I have this label inside ProgressBar that take it's value form the Progressbar value and i want to add the char % after the ProgressBar value. I have tried two options that not working: <Label Content="{Binding Progress}" ContentStringFormat="{}{0} %" /> <Label Content="{Binding Progress, StringFormat={}{0}%}" /> ...

C Preprocessor generate macros by concatenation and stringification [duplicate]

c,concatenation,c-preprocessor,stringification
This question already has an answer here: What are the applications of the ## preprocessor operator and gotchas to consider? 13 answers I have a set of target macros for which I want to generate aliases based on a choosing macro, like so: Choosing macro: #define I2C_MODULE 1 Alias...

Read Multiple Text Files based on dated name and write all to concatenate string

php,string,file,concatenation
I am very new to PHP and stared learning this week and I'm stuck at this problem. I have multiple text files with names based on dates. I need to read every file within a date range and concatenate the text together into one long string. What I have so...

Is it possible to call a variable by concatenating two strings in JavaScript?

javascript,variables,concatenation
I'm trying to condense my code and I've looked at a number of articles on concatenating variables but I haven't been able to get anything to work the way I need it to. Below are two snippets of code. They are functionally identical except the first snippet has variables that...

Behaviour of null in Java

java,nullpointerexception,null,concatenation
This probably looks duplicate of other questions on SO. But, I was wondering the way Java treat null. Eg: public class Work { String x = null; String y; Integer z; public static void main(String arg[]) { Work w = new Work(); w.x = w.x + w.y; // work Line...

Get values of mySQL rows in PHP and echo multiple values of certain rows

php,mysql,concatenation,concat
the title is a little vague on what I want to do so I'll do the explaining here. I have two tables that I get information from, the Book table and Inventory table. I get the Book Title, Author Name and ISBN from Book table, and I concatenate the Quantity...

Get concatenate string of multiple value variable in Javascript

javascript,jquery,concatenation
I've a list of div <div data-attr="sel" data-num="1"></div> <div data-attr="notSel" data-num="2"></div> <div data-attr="sel" data-num="3"></div> I'm tryng to get a string only div with the data-attr="sel" set. function SI_MoveTasks() { var getSelected = document.querySelector('[data-attr~="sel"]'); var selectedNums = getSelected.dataset.num; alert(selectedNums); } Now i get (1), how can i get the concatenate string...

How to console.log an object definition and a text in same string?

javascript,object,concatenation,console.log
I have this JavaScript code: console.log(obj);// [query: "wordOfTheDay"] console.log(note + " : " + obj ); // obj does not show up I want to make "obj" display in the same string as "note" no matter the type it come in as. For example: console.log("text sample : " + obj...

How to join second line to end of first line in python?

python,python-2.7,join,replace,concatenation
I tried to read lines like below: A:129 Tyr -P- 9 - - - 10xR,4xG,3xD,3xK,2xP,2xV,2xY,1xE,1xI,1xL,1xM,1xN,1 xQ,1xT A:181 Ser -P- 8 - - - 9xR,9xS,8xG,4xT,3xD,3xL,3xQ,3xV,2xK,2xM,1xA,1xF,1x H,1xY A:50 His --- 9 - - - 17xL,9xA,4xK,3xI,3xR,3xV,2xN,2xS,1xC,1xE,1xH,1xQ,1 xT Where each Even lines is a continuation of ODD lines but which is split by "\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s"...

How to concatenate a String with AnyObject in Swift?

string,swift,concatenation,string-concatenation
I have a URL (which is a String at the moment), I have query parameters which I want to add to the URL which are of the type AnyObject. Can anyone advise the best way to do this? Thanks in advance...

using range in CONCATENATE function

excel,range,concatenation,libreoffice,calc
I would like to combine the content of many cells in one cell. One possible solution for me is CONCATENATE function. If I use this: =CONCATENATE(B1,C1,D1) it works fine, but for: =CONCATENATE(B1:D1) I am seeing such a value: #VALUE in the cell. How can I define range in a CONCATENATE...

Creating new complex index with pandas Dataframe columns

python,indexing,pandas,concatenation,dataframes
I'm trying to concatenate the columns 'A' and 'C' in a Dataframe like the following to use it as a new Index: A | B | C | ... --------------------------- 0 5 | djn | 0 | ... 1 5 | vlv | 1 | ... 2 5 | bla...

Concatenate two double arrays into a n x 1 cell array using matlab

arrays,matlab,matrix,concatenation,cell
I have an n x 1 double array. A = [1234; 1235; 1236; 1237; 1238]; and a double Scalar. B = [4567] I want to combine (concatenate) these to make a n x 1 cell array that looks like this, C = [1234 4567; 1235 4567; 1236 4567; 1237 4567;...

Java: Why does my book start concatenating string vars with concatenation with an empty string, specifically using System.out.print()?

java,string,concatenation
While reading my school's assigned book for Java I keep seeing string concatenation starting with an empty string. Specifically, I've only seen it when concatenating string variables in System.out.print*() statements (where * is "" or"ln"). I have tried searching for a reason to no avail; I suspect that my wording...

Vector concatenation in MATLAB

matlab,vector,concatenation
I want to concatenate vectors according to another vector values. To simplify question, I'm giving a similar situation: Let assume I have a cell which it has 3 vectors in it (s_i): s_1 = [1 2 3]; s_2 = [2 1 3]; s_3 = [3 1 2]; s_i = {s_1,...

php form mail function

php,email,variables,concatenation
I am using a mail function to mail it to my email adress, but i want it to send me a message with variables in it. (I have tried to concatenate it with concatenation point, but it doesn't seem to work, or I did not use it right) The code:...

Why in C++ when i concat a string with '+' like it don't concat but remove first char of the string [duplicate]

c++,string,concatenation,cout
This question already has an answer here: Why in the code “456”+1, output is “56” [duplicate] 3 answers i was learning C++ after 6-7 years of java and i have encouter a problem, in this snippet that instead of "concat" it's just remove the n character as the input...

TypeError: cannot concatenate 'str' and '_sre.SRE_Match' objects

python,regex,concatenation
I'm retrieving a string with regex, and I'm trying to concatenate that with other pieces of string. Error: TypeError: cannot concatenate 'str' and '_sre.SRE_Match' objects Example: original_string = "ABC 4x DEF" regex = re.search(r"(\d)X|x", original_string) new_string = "+" + regex + "00" print "New string: %s" % new_string new_string should...

Combine 2D matrices to form 3D one in Matlab

arrays,matlab,concatenation
I have 3 20x2 double arrays A, B and C. I want to combine them in one 3d array D so that D(:,:,1) will return A, D(:,:,2) will return B and D(:,:,3) will return C.

How do I prepend/append (concatenate) data to each row in a MySQL result or data set?

mysql,concatenation
Here's a query I'm making: SELECT sku FROM items With results of: 18972 81771 29883 I want to add data to the beginning and end of each row that is returned so it looks something like this: sku18972a sku81771a sku29883a What do I need to add to my SELECT statement...

Concatenate shows the second and third value except the first value

excel,excel-vba,concatenation
I have this macro that concatenates values from 3 cells, the problem is that it only concatenates the 1st and 2nd values, before it only concatenated the the first value was 3, the second value was march and the third value was 2015, so the result just gives me "...

Inserting tuples in a list Ocaml

list,tuples,ocaml,concatenation
I have declared a list l=[];; and now trying to append tuples into this list using '@'. But I am not able to do so. Can anyone please help me sorting this out. let l = [] for x = 1 to 10 do l <- [email protected][(x,x+10)] done;; And want...

split string column by “_”, drop the preceding text, recombine str by “_” in pandas

python,pandas,concatenation,dataframes
>e = {0: pd.Series(['NHL_toronto_maple-leafs_Canada', 'NHL_boston_bruins_US', 'NHL_detroit_red-wings', 'NHL_montreal'])} >df = pd.DataFrame(e) >df 0 0 NHL_toronto_maple-leafs_Canada 1 NHL_boston_bruins_US 2 NHL_detroit_red-wings 3 NHL_montreal I want to: 1) split the above dataframe (Series) by '_' 2) drop the 'NHL' string 3) recombine the remaining text by '_' 4) attach the result in #3 to...

Red-Black tree: Split/Concatenate in log(n) time

algorithm,split,concatenation,binary-search-tree,red-black-tree
According to Ron Wein your able to do split and concatenation of red-black tree's in O(log(n)) time. See his artikle: Efficient Implementation of Red-Black Trees with Split and Catenate Operations However I'm still not convinced that the running time of split really is true. The idea is that split uses...

SQL count date time

sql,count,concatenation
I have to concatenate the date and time portion of two fields, which I have managed to do, then I need to test if the result is < getdate() select count(cast(cast(DischargeDatenew as date) as datetime) + cast(DischargeTime as time))as Requiredby FROM [dbo].[Main] where Location = 'Home' and ScriptTypeID = '1'...

How to bit-shift and concatenate to get correct result?

c#,concatenation,bit,bit-shift,uint16
I'm currently struggling with modbus tcp and ran into a problem with interpreting the response of a module. The response contains two values that are encoded in the bits of an array of three UInt16 values, where the first 8 bits of r[0] have to be ignored. Let's say the...

concatenation of distinct substrings

java,string,out-of-memory,substring,concatenation
question - Arrange all the distinct substrings of a given string in lexicographical order and concatenate them. Print the Kth character of the concatenated string. It is assured that given value of K will be valid i.e. there will be a Kth character Input Format First line will contain a...

String concatenation in perl to a variable

perl,concatenation
I have a string like this: my $masterP = "A:B:C a:b:c a:c:b A:C:B B:C:A"; my (@scen) = split (/ /, $$masterP); foreach my $key (@scen) { my ($string1, $string2, $string3) = split (/:/,$key); my $new = "${string1}_${string2}"; my $try .= $try."$new"; } print "$try\n"; I am expecting $try to print:...

Is concatenation inside an ini file possible?

php,concatenation,ini
Is there any standard way to concatenate variables of an .ini-file? The .ini-file is parsed by PHP, so I know that it's possible to do it in PHP, but is it possible inside an .ini-file? Example for the file: ; definition of the server root [root] path=/var/path/to/server/root/ url=http://www.domain.xx/ And I'd...

Numpy concatenate 2D arrays with 1D array

python,arrays,numpy,concatenation
I am trying to concatenate 4 arrays, one 1D array of shape (78427,) and 3 2D array of shape (78427, 375/81/103). Basically this are 4 arrays with features for 78427 images, in which the 1D array only has 1 value for each image. I tried concatenating the arrays as follows:...

Use php variable in sql statement with concatenation

php,sql,string,variables,concatenation
I have a variable below (storecode) which is getting it's value from the user's input (120) $storecode = $_POST['storecode']; The sql which works otherwise in PL/SQL Developer is Select mydate from [email protected]_database.p120081; I am trying to put the $storecode variable in replacement of the "120" and then concatenate "081" so...

Matlab: how can I create one grid by joining two gridded rectangles of different size (or two matrices with different dimensions)?

matlab,concatenation
I have spent all weekend trying to do something in Matlab that seems like it should be very simple. I am not an experienced Matlab user. I want to calculate flow through a tank. This requires me to define a rectangular geometry (the tank), then divide it into cells/elements (a...

How to concatenate a string and an integer

c++,string,concatenation
On compiling I am not able to concatenate the string.I am a little confused as to how do I concatenate.I tried to typecast and then concatenate,but that too throws an error. #include<iostream> #include<cstring> using namespace std; string whatTime(int n) { int h=n/3600; int m=n/60; int s=n%60; string s1=h + ":"...

Python 3.x - Using the sum function to concatenate strings in a list

python,python-3.x,sum,concatenation
x= ['Good', 'morning'] # example list of strings I have to use sum(x) to concatenate both and print (x). I'm having trouble converting the list into integers for the sum function to work. >>>print (sum(x)) 'Goodmorning' ...

Concat Program, Weird symbols

c++,concatenation
I am following the 'C++ for Dummies' section on concatenating strings. However, my program below outputs the two strings concatenated but with a load of weird symbols in the middle. #include "stdafx.h" #include <iostream> #include <cstdlib> #include <cstdio> #include <string> using namespace std; void concatString(char szTarget[], const char szSource[]); int...

c++ from macros to templates

c++,templates,macros,concatenation,c-preprocessor
I'm trying to change some macros (we have a bunch of them) for function templates. Many times, I have the following scenario: #include <iostream> void function_A( void ) { std::cout << "function A" << std::endl; } void function_B( void ) { std::cout << "function B" << std::endl; } #define FOO(...

Split string and append to array

ruby,string,split,concatenation
I would like to split a string and append the split result to two separate arrays simultaneously. Is there a way to do this? For example: mystrings = ['abc:def', 'ghi:jkl', 'mno:pqr'] first = [] second = [] mystrings.each do |string| first, second << string.split(':') end This doesn't work. But I...

Oracle SQL TOAD - Update Year in a variable ( Concat string + Year ) depending of Sysdate

sql,oracle,date,concatenation
I would like to Update Year in a variable ( string + Year ) depending of Sysdate I want to execute a 'select' command more or less like that : If sysdate is between 1st of October and 31 December select * from table where table.date between CONCAT ('1/10/','Variable_Year_Current' )AND...

Android carriage return inside concatenated string

android,textview,concatenation,carriage-return
A quick question please. I am reading an NFC tag and showing the result on the screen of my device and this is how it appears: The content of the tag is : bla bla bla I want to have 2 lines appearing as this: The content of the tag...

How can I convert and integer into a string? [duplicate]

python,string,integer,concatenation
This question already has an answer here: How to print list item + integer/string using logging in Python 1 answer I am coding in Python, and have reached an error that I cannot seem to solve. Here's the part of the code that it affects. import random a =...

MYSQL - append or insert value into a column depending on whether it's empty or not

php,mysql,string,concatenation
As title says, im trying to append a string to a VARCHAR column in my table. The string is something like " //string ", forward slashes will be used later to explode the string to an array in PHP. I was wondering if there's a way in MYSQL to perform...

c++ concatenating macro definitions

c++,macros,concatenation,preprocessor
In C++ (G++ to be specific), can one concatenate two macro definitions, without spaces, to create a 3rd definition? For example, how to I take #define _LOAD _mm256_load #define _FLOAT ps and operate on them thusly #define _LOAD_FLOAT ****do something with _FLOAT and _LOAD here ***** to create a definition...

concatenating string and int for filename in cpp

c++,string,loops,concatenation
As a newbie to C++, I have looked at C++ concatenate string and int, but my requirements are not quite the same. I have a sample code such as follows: #include <iostream> #include <fstream> #include <stdio.h> using namespace std; int main () { std::string name = "John"; int age =...

How can I pass the result of a command to another command in one line?

bash,shell,command-line,concatenation,command-line-interface
How can I pass minutes since midnight to a cli in one line? This works: echo $[ ( ( `date "+%s"` - 28800 ) % 86400 ) / 60 ] // Correctly returns minutes since midnight in PST But how can I pass the same into another command? This doesn't...

Concatenating positions into genomic segments

r,concatenation,bioinformatics,bioconductor,genome
I would like to concatenate all rows which have more than 0.955 of similarity score. The Aboand Bel collumns represents the similarity score with above and below rows, respectively. In the following input df I have 10 genomic probes (NAME collumn) which is concatenated in just 4 genomic segments (dfout)....

How to concatenate date and time columns based on value from another column in sql?

mysql,sql,datetime,concatenation
I have three Columns in my SQL Table: Date, Time, and Check. I want to concatenate Date and Time value together into a datetime column based on Check Column. The Check column contains a varchar value either 'Today' or 'Tomorrow'. So, if the Check value is 'Today', the Time should...

Add spaces and/or breaks in concatenated text from variables of values input fields in jQuery

jquery,variables,input,concatenation,value
Trying to get some spaces and/or breaks in the textarea that has its content added dynamically depending on the amount and type of input based o values. All works as it should except the textarea where all the values are added together as a string without having any breaks or...

DataColumn: combine columns and values into a string

c#,linq,concatenation,value,datacolumn
I'd like to use LINQ to take a datarow, and parse out the datacolumn names with their values. So if I had a dataRow with the following columns and values: DataColumn column1 with value '1' DataColumn column2 with value 'ABC' I'd like to have a string returned as "column1 =...

Best way to detect changes when values might not exist anymore?

javascript,jquery,jquery-ui,comparison,concatenation
I've been trying to detect changes in multiple inputs on a web page. To do that, I used a query like this: $(.InputClass).data("InitialValues",$(.InputClass).serialize()) (I'm not in front of my code sadly but it should look like this) Then later I compared the values in .data with the new values and...

bash: How can I assemble the string: `“filename=output_0.csv”`

string,bash,concatenation
I am using a bash script to execute a program. The program must take the following argument. (The program is gnuplot.) gnuplot -e "filename='output_0.csv'" 'plot.p' I need to be able to assemble the following string: "filename='output_0.csv'" My plan is to assemble the string STRING=filename='output_0.csv' and then do the following: gnuplot...

Bash string concat does not work - Result of concat is empty

string,bash,concatenation
I try to build a Git prepare-commit-msg hook, that provides the following output for the git bash (mingw32): <file1>: - <file2>: - ... And #!/bin/bash git diff --cached --name-status | while read line; do echo $OUTPUT$line$':\n - \n'; done works great git diff --cached --name-status prints <mode>\t<filePath> for each file...

Should I use operator+= instead of operator+ for concatenating std::string?

c++,append,concatenation,stdstring
Is there a reason that I often see this construct: std::string myString = someString + "text" + otherString + "more text"; ... instead of this (which I very seldom see): std::string myString; myString += someString += "text" += otherString += "more text"; Reading the std::string API, it seems to me...

Mapping separate fields into one string using Automapper

c#,string,field,concatenation,automapper
I have spent a couple of days trying to track this down without any luck. I have a table of addresses. Each row has 4 address fields. I want to map them to another object that has one field that is a single string made up of the 4 fields,...

in php concatenation of '<' with any string becomes empty string

php,string,concatenation
I have a PHP socket connection. I send a request and receive its response. The response is in xml format and contains '<'. I want to concatenate strings and build one string of complete response. But when I put '<' at the beginning of string the whole string becomes null:...

Concatenate excel cells with numbers without summing

r,excel,concatenation
I know you can use the concatenate function in excel to combine two strings in two different cells into one cell, but how do I do the same for cells with numbers in them? I have two columns as seen in the image below (I have started the process by...

Optimise string building with concatenation in PHP loop

php,arrays,for-loop,parameter-passing,concatenation
I have a PHP function that do batch insertion into a MYSQL table. The function take input parameter as an array, it then loop thru the array to build the insert query like this: public function batchInsert($values){ $nbValues = count($values); $sql = 'INSERT INTO vouchers (`code`,`pin`,`owner_id`,`value`,`description`,`expire_date`,`lifetime`) VALUES '; for ($i=0;...

concatenate two byteBuffers to a single

java,concatenation,bytebuffer
Hi I've 2 byteBuffers and I want to concatenate them together to a single byteBuffer. I found a similar question here but none of the suggestions there worked for me.

Create a new column in my SQL View - Column must be two other columns combined

sql,sql-server,tsql,concatenation
I am trying to create a new view, but I also want this view to have a new column. The new column must be StkCode and Description_1 combined. For example: If my StkCode is DX11122 and Description_1 is Vanilla Powder; I want a field that will read as follows: "Vanilla...

Concatenate cells flexibly

matlab,concatenation
I have a structure P with various numbers of cells. For instance, P.Block1.onsets, P.Block2.onsets, P.Block3.onsets, P.Block4.onsets, etc. Onsets are 1x16 cells (i.e., there are 16 cells), each cell contains 1x4 double. So P.Block1.onsets{1,2} could be something like this [12, 37, 108, 226]. P only contains field BlockX and nothing else....

How to expand a string within a string in python?

python,string,dictionary,concatenation,list-comprehension
I have a string that looks like this: 1 | xxx | xxx | xxx | yyy*a*b*c | xxx I want to expand the yyy*a*b*c part so that the string looks like this: 1 | xxx | xxx | xxx | yyya | yyyb | yyyc | xxx I actually...

String Concatenation Operator + Ambiguity

string,operator-overloading,operators,concatenation,language-design
I am currently working on a JVM-based programming language that supports operator overloading and custom operators. I wanted to stick to Java and use the + operator for String concatenation, and this is implemented and works flawlessly in my language. However, the operator is also used in various other places,...

R: Concatenate values of list components by another list defining which ones go together

r,list,indexing,concatenation
I have two lists. lst1 contains character vectors which represent variable names: lst1 <- list(c("var1", "var2"), "item1", c("var12", "var15", "var17"), c("item3", "item5", "item7"), "var22", c("var27", "var29", "var33", "var34")) As you can see some components in lst1 contain one or more variable names. lst2contains values for each variable name in lst1,...

Find Biggest Concatenation Word in List

c#,arrays,concatenation
I have some code that doesn't work as expected. As output, I get: Concatenation.Concatenation+ConcatWord I have no idea how to make it work as I would like. It should output the biggest concatenation word in the array and the number of its characters. The input might be: string[] words =...

How to use join to fill missing values of a column - Python Pandas?

python,join,pandas,left-join,concatenation
To be concrete, say we have two DataFrames: df1: date A 12/1/14 3 12/2/14 NaN 12/3/14 2 12/2/14 NaN 12/4/14 NaN 12/6/14 5 df2: B 12/2/14 20 12/4/14 30 I want to do kind of a left outer join to fill the missing values in df1, and generate df3: date...

String concatenation, error

c++,string,concatenation
Container.cc: In member function ‘std::string Container::tostring()’: Container.cc:125:27: error: invalid operands of types ‘const char*’ and ‘const char [2]’ to binary ‘operator+’ cadena= "("+ this->id+ ","+this->weight +","+ this->price+")"; How I can solve this error, is c++ This is the code: string Container::tostring() { cadena= "("+ this->id+ ","+this->weight +","+ this->price+")"; return...

MATLAB - Adding a field to the begining of an existing struct

matlab,data-structures,struct,concatenation
I have a 1x100000 struct in MATLAB. It occurs to me that I need to add a field to it, which is easy and fine.. however i can't seem to add the field to the beginning i.e. make the new field the first field. my struct looks like this DB(kk).StudyDate...

VB.net txt text file merge / concatenate all files

vb.net,text-files,concatenation
I have combined all logfiles by using the following code and shelling to dos. pi2.Arguments = "/c for /r c:\logs " + "%F in (*.*) do @type " + """%F """ + ">>c:\logs\Master" pi2.FileName = "cmd.exe" p2.StartInfo = pi2 p2.Start() p2.WaitForExit() This put all the information in one file but...

List Concatenation, Adding elements that finish with ':' to a list, and others to a sublist

python,list,python-3.x,concatenation
I need to format the output of a list in order to have all elements that finish with : as first elements, while the rest in a sublist of that list. For example: Suppose we have: A: B, C B: D, F | G What i have done until now...

Find biggest concatenation word in array

c#,concatenation
I'm new to C#, can someone help me understand why my code doesnt work? Seems like there something wrong with variable word which needs to be returned, but I don't understand what. public virtual bool concatOnly() { int tmp = 0; foreach (string word in words) { tmp += word.Length;...

Concatenate plain char and string?

c++,string,char,concatenation
im getting totally confused by this seemingly simple problem. I have a pain old char, and I want to concatenate it in the middle of a string. Like so. string missingOptionArg(char missingArg) { return "Option -" + missingArg + " requires an operand"; } I was guessing the + operand...

SQL Server controlling spaces when concatenating

sql-server,sql-server-2008,concatenation
This seems a simple question, but it is something I always seem to be up against. When concatenating two (or more) fields in SQL Server with adding a space between fields like: SELECT Field1 + ' ' + Field2 FROM table If Field1 or Field2 may be null, So we...

Concatenate cells into a string with separator pandas python

python,string,pandas,concatenation
Given the following: df = pd.DataFrame({'col1' : ["a","b"], 'col2' : ["ab",np.nan], 'col3' : ["w","e"]}) I would like to be able to create a column that joins the content of all three columns into one string, separated by the character "*" while ignoring NaN. so that I would get something like...

How to concat to access cell using vb.net

sql,vb.net,ms-access-2010,concatenation
I want to concat(add to what already exist) to an access cell using the text from a vb.net textbox. I tried using UPDATE but I'm getting a syntax error. This is what I tried so far Dim ds As New DataSet() Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\equip_full.mdb;Jet OLEDB:Database Password=matt"...

How to cleanly use: const char* and std::string?

c++,string,char,concatenation
tl:dr How can I concatenate const char* with std::string, neatly and elegantly, without multiple function calls. Ideally in one function call and have the output be a const char*. Is this impossible, what is an optimum solution? Initial Problem The biggest barrier I have experienced with C++ so far...

Adding two numbers becomes concatenating two numbers, but the result is a number value? Javascript [duplicate]

javascript,jquery,concatenation
This question already has an answer here: Sum of two input value by jquery 5 answers I have three inputs that need to be calculated. I used the .val() method in jQuery to get the value of the input and calculate them with following: $("document").ready(function(){ $("#calculate").click(function(){ document.getElementById("result").innerHTML="$"+($("#einc").val()+$("#iinc").val()-$("#slint").val()); $("#result").css("display","inline"); });...

Difference in time between list append and + operator that I can't explain

python,list,append,concatenation
I'm trying to use time.clock() in Python 3.4 on Windows 7 to compare the speed of append and +=. (It's an exercise from Chapter 10 of Think Python.) Here's my code: import time fin = open('words.txt') print("Comparing the time it takes to make a list with append vs. the +...

Macro to merge and concatenate cells in Excel for rows in which information on other columns matches

excel,excel-vba,merge,concatenation
apologize if this is a common post, but couldn't find something that fully applies to me. It's a very similar post to (except that instead of just merging the 2 cells, i am looking to merge and concatenate): Macro to merge cells in Excel for rows in which information in...

Array stacking/ concatenation error in python

python,arrays,numpy,concatenation
I am trying to concatenate two arrays: a and b, where a.shape (1460,10) b.shape (1460,) I tried using hstack and concatenate as: np.hstack((a,b)) c=np.concatenate(a,b,0) I am stuck with the error ValueError: all the input arrays must have same number of dimensions Please guide me for concatenation and generating array c...

Comparing Columns in Multiple Excel Tabs using INDIRECT

excel,concatenation,excel-indirect
I am looking for a very broad and dynamic way to check and see if the content in two columns are the same (the columns are in two different tabs). The content varies from text, numbers, and dates. So far the only way I have tried doing this is by...