string-concatenation

Concatenating strings in VBA

为君一笑 提交于 2019-12-01 15:09:50
问题 I'm maintaining an application written in Microsoft Access with VBA. I'm glancing over my code and have just noticed I have subconsciously been concatenating strings together with the plus (+) symbol instead of the ampersand. It's been a few years since I've coded in VB6. Could this cause any issues? Everything seems fine and it will only take a few minutes to fix, I'm just curious as to whether I'm technically doing anything wrong. 回答1: The ampersand is explicitly a string operation, while

use both html and php in echo and href line

╄→尐↘猪︶ㄣ 提交于 2019-12-01 13:48:18
I have the variable: $myvar = 'myarchive.pdf'; How can I embedd it to this: echo('<tr> <td> <a href="nextpage.php?file=trial.pdf"> download now </a> </td> </tr>'); I wonder if there is a way to do it like this: echo('<tr> <td> <a href="nextpage.php?file=".'$myvar'.> download now </a> </td> </tr>'); You are not appending the variable to the string properly. Also you have to enclose nextpage.php?file=variable within quotes. But you are closing it before the variable name. <a href="nextpage.php?file=".'$myvar'.> ^ So try with echo('<tr> <td> <a href="nextpage.php?file='.$myvar.'"> download now <

psycopg2 difference between AsIs and sql module

拈花ヽ惹草 提交于 2019-12-01 12:59:50
To choose dynamically a table name in a query I used to use AsIs() from psycopg2.extensions ( http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.AsIs ), with the following syntax: cur.execute("SELECT * FROM %s WHERE id = %s;", (AsIs('table_name'), id)) However, the documentation now recommends to use the new psycopg2.sql module available in version 2.7 ( http://initd.org/psycopg/docs/sql.html#module-psycopg2.sql ) with the following syntax: from psycopg2 import sql cur.execute( sql.SQL("SELECT * FROM {} WHERE id = %s;") .format(sql.Identifier('table_name')), (id, ) What's the

psycopg2 difference between AsIs and sql module

拜拜、爱过 提交于 2019-12-01 10:31:18
问题 To choose dynamically a table name in a query I used to use AsIs() from psycopg2.extensions ( http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.AsIs ), with the following syntax: cur.execute("SELECT * FROM %s WHERE id = %s;", (AsIs('table_name'), id)) However, the documentation now recommends to use the new psycopg2.sql module available in version 2.7 ( http://initd.org/psycopg/docs/sql.html#module-psycopg2.sql ) with the following syntax: from psycopg2 import sql cur.execute(

Concatenate two cell arrays of strings with a space in between?

╄→гoц情女王★ 提交于 2019-12-01 09:53:31
How can I concatenate: A = {'hello'; 'hi'; 'hey'} with B = {'Ben'; 'Karen'; 'Lisa'} with a space in between to get: C = {'hello Ben'; 'hi Karen'; 'hey Lisa'} Is there a fast non-looping way? You can use strcat() , although it performs a loop: strcat(A,{' '}, B) where the blank is preserved by enclosing it within a cell. Alternatively, FEX:CStrCatStr is a mex routine which achieves a 10x speedup (depending on testing environment): CStrCatStr(A,' ', B) A faster (albeit less elegant) alternative to strcat that concatenates strings is a combination of the sprintf and textscan commands: C = [A; B];

Why string concatenation takes so long time? [duplicate]

扶醉桌前 提交于 2019-12-01 09:27:49
问题 This question already has answers here : StringBuilder vs String concatenation in toString() in Java (18 answers) Closed 4 years ago . I am concatenating a String in a loop but it takes ages, why is that? for (String object : jsonData) { counter++; finalJsonDataStr += object; } Variable object is a piece of JSON, up to 70 chars and the loop goes approx 50k times. I understand some people advice StringBuffer or StringBuilder but this link says, it has no performance improvements: StringBuilder

pyspark generate row hash of specific columns and add it as a new column

拈花ヽ惹草 提交于 2019-12-01 08:26:05
I am working with spark 2.2.0 and pyspark2. I have created a DataFrame df and now trying to add a new column "rowhash" that is the sha2 hash of specific columns in the DataFrame. For example, say that df has the columns: (column1, column2, ..., column10) I require sha2((column2||column3||column4||...... column8), 256) in a new column "rowhash" . For now, I tried using below methods: 1) Used hash() function but since it gives an integer output it is of not much use 2) Tried using sha2() function but it is failing. Say columnarray has array of columns I need. def concat(columnarray): concat_str

Concatenation of strings by for xml path

折月煮酒 提交于 2019-12-01 08:22:02
Hi! Today I learned for xml path technique to concatenate strings in mssql. Since I've never worked with xml in mssql and google hasn't helped, I need to ask you. Let's imagine the default case. We need to concatenate some strings from a table: declare @xmlRepNames xml = ( select ', [' + report_name + ']' from ( select distinct report_order, report_name from #report ) x order by report_order for xml path(''), type) select stuff((select @xmlRepNames.value('.', 'nvarchar(max)')), 1, 1, '') So I get smth like this: [str1], [str2], [strn] Ok. It works fine. But I have two very similar concatenate

Compilation of string literals

筅森魡賤 提交于 2019-12-01 06:48:03
Why can two string literals separated by a space, tab or "\n" be compiled without an error? int main() { char * a = "aaaa" "bbbb"; } "aaaa" is a char* "bbbb" is a char* There is no specific concatenation rule to process two string literals. And obviously the following code gives an error during compilation: #include <iostream> int main() { char * a = "aaaa"; char * b = "bbbb"; std::cout << a b; } Is this concatenation common to all compilers? Where is the null termination of "aaaa"? Is "aaaabbbb" a continuous block of RAM? If you see e.g. this translation phase reference in phase 6 it does:

Row-wise sort then concatenate across specific columns of data frame

强颜欢笑 提交于 2019-12-01 06:06:21
(Related question that does not include sorting. It's easy to just use paste when you don't need to sort.) I have a less-than-ideally-structured table with character columns that are generic "item1","item2" etc. I would like to create a new character variable that is the alphabetized, comma-separated concatenation of these columns. So for example, in row 5, if item1 = "milk", item2 = "eggs", and item3 = "butter", the new variable in row 5 might be "butter, eggs, milk" I wrote a function f() below that works on two character variables. However, I am having trouble Using mapply or other