Questions tagged [concatenation]

Joining of two or more sequences into a single sequence.

Concatenation refers to the joining of two or more elements into a single element.

In programming, this can refer to

  • concatenation, which joins multiple strings into a single string
  • concatenation, where one or more arrays are combined (mostly appended) to make a new array
  • specific concatenation functions that combine elements along a specified dimension (horizontally, or vertically for example), replicate and tile existing elements, and so forth.
12037 questions
131
votes
13 answers

Concatenate text files with Windows command line, dropping leading lines

I need to concatenate some relatively large text files, and would prefer to do this via the command line. Unfortunately I only have Windows, and cannot install new software. type file1.txt file2.txt > out.txt allows me to almost get what I want,…
James
  • 65,548
  • 14
  • 155
  • 193
131
votes
7 answers

How to use GROUP_CONCAT in a CONCAT in MySQL

If I have a table with the following data in MySQL: id Name Value 1 A 4 1 A 5 1 B 8 2 C 9 how do I get it into the following format? id Column 1 …
Biswa
  • 1,501
  • 3
  • 11
  • 17
129
votes
6 answers

Oracle SQL, concatenate multiple columns + add text

So I basically wanna display this (whole row in ONE column): I like [type column] cake with [icing column] and a [fruit column]. The result should be: Cake_Column ---------------- I like chocolate cake with whipped_cream and a cherry. I like…
Thundordan
  • 1,299
  • 2
  • 8
  • 4
128
votes
14 answers

Efficient string concatenation in C++

I heard a few people expressing worries about "+" operator in std::string and various workarounds to speed up concatenation. Are any of these really necessary? If so, what is the best way to concatenate strings in C++?
sneg
  • 2,088
  • 4
  • 19
  • 23
127
votes
3 answers

Creating C macro with ## and __LINE__ (token concatenation with positioning macro)

I want to create a C macro that creates a function with a name based on the line number. I thought I could do something like (the real function would have statements within the braces): #define UNIQUE static void Unique_##__LINE__(void) {} Which I…
DD.
  • 1,273
  • 2
  • 9
  • 4
121
votes
11 answers

How can I combine multiple rows into a comma-delimited list in Oracle?

I have a simple query: select * from countries with the following results: country_name ------------ Albania Andorra Antigua ..... I would like to return the results in one row, so like this: Albania, Andorra, Antigua, ... Of course, I can write…
rics
  • 5,494
  • 5
  • 33
  • 42
119
votes
7 answers

How can strings be concatenated?

How to concatenate strings in python? For example: Section = 'C_type' Concatenate it with Sec_ to form the string: Sec_C_type
michelle
  • 1,241
  • 2
  • 8
  • 4
117
votes
6 answers

MySQL select with CONCAT condition

I'm trying to compile this in my mind.. i have a table with firstname and lastname fields and i have a string like "Bob Jones" or "Bob Michael Jones" and several others. the thing is, i have for example Bob in firstname, and Michael Jones in…
Alex K
  • 6,737
  • 9
  • 41
  • 63
114
votes
3 answers

Concatenate rows of two dataframes in pandas

I need to concatenate two dataframes df_a and df_b that have equal number of rows (nRow) horizontally without any consideration of keys. This function is similar to cbind in the R programming language. The number of columns in each dataframe may be…
user1140126
  • 2,621
  • 7
  • 29
  • 34
114
votes
5 answers

How to quote a quote with the CONCATENATE function in OOCalc

In OOCalc I want to use the CONCATENATE function to add quotes to each string in column A. So in cell B1 I want to do: =CONCATENATE("\"",A1,"\"") OOCalc does not like this, or without the escaping backslash. Does anyone know how to do this, or…
Richard H
  • 38,037
  • 37
  • 111
  • 138
112
votes
5 answers

Concatenation of strings in Lua

In many languages you can concatenate strings on variable assignment. I have a scenario, using the Lua programming language, where I need to append the output of a command to an existing variable. Is there a functional equivalent in Lua to the below…
John Mark Mitchell
  • 4,522
  • 4
  • 28
  • 29
108
votes
6 answers

pandas concat columns ignore_index doesn't work

I am trying to column-bind dataframes and having issue with pandas concat, as ignore_index=True doesn't seem to work: df1 = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'], 'B': ['B0', 'B1', 'B2', 'B3'], 'D':…
muon
  • 12,821
  • 11
  • 69
  • 88
100
votes
9 answers

Why does C not allow concatenating strings when using the conditional operator?

The following code compiles without problems: int main() { printf("Hi" "Bye"); } However, this does not compile: int main() { int test = 0; printf("Hi" (test ? "Bye" : "Goodbye")); } What is the reason for that?
José D.
  • 4,175
  • 7
  • 28
  • 47
99
votes
22 answers

How can I merge 200 CSV files in Python?

I here have 200 separate CSV files named from SH (1) to SH (200). I want to merge them into a single CSV file. How can I do it?
Chuck
  • 1,051
  • 1
  • 8
  • 6
98
votes
5 answers

How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x)

Note: This question is only relevant for Grunt 0.3.x and has been left for reference. For help with the latest Grunt 1.x release please see my comment below this question. I'm currently trying to use Grunt.js to setup an automatic build process for…
Jasdeep Khalsa
  • 6,740
  • 8
  • 38
  • 58