concatenation

concat two int values in postgresql

一个人想着一个人 提交于 2019-12-08 15:59:24
问题 I have 7 integer values (with 3,1,3,4,4,5,4 digits respectively) and I have to concatenate them to a single integer (i.e a 24 digit no.) . I tried to do it like this create or replace function gen_id(int,int,int,int,int,int,int) returns bigint as $$ declare id bigint; begin id = $1 * 1000000000000000000000 + $2 * 100000000000000000000 + $3 * 100000000000000000 + $4 * 10000000000000 + $5 * 1000000000 + $6 * 10000 + $7; return id; end; $$ language plpgsql; select * from gen_id(100,1,101,1000

concatenate stringstream in c++

前提是你 提交于 2019-12-08 15:58:44
问题 How can I concatenate two stringstreams? #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <fstream> #include <sstream> #include <string> #include "types.h" int main () { char dest[1020] = "you"; char source[7] = "baby"; stringstream a,b; a << source; b << dest; a << b; /*HERE NEED CONCATENATE*/ cout << a << endl; cout << a.str() << endl; return 0; } The output is the following in both tries: 0xbf8cfd20 baby0xbf8cfddc The desired output is babyyou . 回答1:

Using + to concat string in Java

青春壹個敷衍的年華 提交于 2019-12-08 14:56:44
问题 I have a huge string as below : String str = "aaaaaaa" + "bbbbbbbb" + "cccccccc" .... + "zzzzzzzz"; // about 200 lines long Is it a big waste of memory? Will it be better to put it in one line or use StringBuilder ? This is done to create a long sql. 回答1: No. The compiler will perform the concatenation at compile time if all your strings are constant (as they are in your question). So that ends up performing better than the StringBuilder version. It will use StringBuilder (or StringBuffer )

Python Error TypeError: cannot concatenate 'str' and 'float' objects [duplicate]

人盡茶涼 提交于 2019-12-08 14:23:58
问题 This question already has answers here : Making a string out of a string and an integer in Python [duplicate] (6 answers) Closed 2 years ago . I am new with Python programming. I keep getting the below error on the 'str'. When I added the + str, it didnt work. wkt = "POINT("+ geoPoint["lat"] +" " + geoPoint["lon"] + ")" TypeError: cannot concatenate 'str' and 'float' objects Any advice on how I can fix this error? 回答1: The simplest solution would look like this: wkt = "POINT("+ str(geoPoint[

backslash removal while constructing absolute path

笑着哭i 提交于 2019-12-08 14:12:34
问题 I want to construct an absolute path with '.zip' in the end, Following is the snippet, path='folder/file' absPath=os.path.join('E:/',path,'.zip') I am getting the following output for this, E:/folder1/file\.zip Required output, E:/folder/file.zip How can I avoid the \ before .zip while concatenating?? 回答1: Are you building paths for windows? Seemingly so because you use a drive letter at the start and because os.path.join is using backslashes to build the path. If so, you are going to have

C preprocessor macro: concatenation (example for Fortan90)

佐手、 提交于 2019-12-08 11:21:08
问题 I am stuck with the following problem: I have the two following correct working macros (expanding to Fortran90 code): #define ld_dx(A) ( (A(ixp1)-A(ix ))/(dx) ) #define rd_dx(A) ( (A(ix )-A(ixm1))/(dx) ) (Note: these macros depend on the following additional macros: #define ix 2:nx-1 #define ixp1 1+ix+1 #define ixm1 -1+ix-1 And they depend also the declarations: integer, parameter :: nx = 100, dx = 1 ) In my code I can use these macros by a call as for example X = X + ld_dx(Y) or: X = X + rd

Using += for strings in a loop, is it bad practice?

一个人想着一个人 提交于 2019-12-08 08:55:40
问题 I saw this method of string building used in another post which has since been removed. One of the comments described the practice as "career limiting" Why is this so? 回答1: I'll answer assuming you're talking of Java here. I can think of more than one reason. The first is that Java strings are immutable, and when you do a += to concatenate strings, a new String object is created, and the reference to that is assigned to your string variable. So when you do this: for (int i = 0; i < 100; i++)

Cannot concatenate strtok's output variable. strcat and strtok

爷,独闯天下 提交于 2019-12-08 07:26:59
问题 I’ve spent hours on this program and have put several hours online searching for alternatives to my methods and have been plagued with crashes and errors all evening… I have a few things I'd like to achieve with this code. First I’ll explain my problems, then I’ll post the code and finally I’ll explain my need for the program. The program outputs just the single words and the concatenate function does nothing. This seems like it should be simple enough to fix... My first problem is that I

How to append column number in front of every element?

五迷三道 提交于 2019-12-08 06:40:52
问题 Here is a simple data: a <- c( "a" ,"a") b <- c("b", "b") df <- data.frame(a, b) df[] <- paste0(1:2, unlist(df[,1:2])) a b 1 1a 1b 2 2a 2b The output I am looking for is: a b 1 1a 2b 2 1a 2b Any efficient way to do this? This works, but I am sure there is a much better way. Thanks! df2[] <- paste0(col, unlist(t(df2[,1:2]))) t(df2) 回答1: Try this: df[] <- Map(paste0, seq_along(df), df) df ## a b ## 1 1a 2b ## 2 1a 2b 来源: https://stackoverflow.com/questions/52708734/how-to-append-column-number

MySQL concatenation and Illegal mix of collations error

蹲街弑〆低调 提交于 2019-12-08 06:31:49
问题 I keep getting an error using MySQL 5.5.27 when trying to concatenate some values. I've searched and seen a bunch of charset answers (which admittedly is a TAD over my head), but I've converted all my tables to Charset utf8-unicode-ci and still get the error. Surely there is a way to concatenate these values, but I just don't know how. I'm an Oracle guy that is relatively new to MySQL. Here is the SQL line: concat(pl.last_name,'-',format(money,0)) I get: #1270 - Illegal mix of collations