string-concatenation

Merge two JSON objects programmatically

删除回忆录丶 提交于 2019-11-29 04:33:06
I have two JSON objects here, generated through the Google Search API. The URL's of these objects can be found below. http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=hello%20world&rsz=large http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=hello%20world&rsz=large&start=8 As you can see the first URL returns the first eight results, whilst the second one returns the next eight. Instead of checking these results separately I'd like to programmatically merge them into one JSON object and pass them through as the first sixteen results. I've attempted this with a couple of

Merging a list of Strings using mkString vs foldRight

喜欢而已 提交于 2019-11-29 03:58:11
I am currently trying out things in Scala, trying to get accustomed to functional programming as well as leaning a new language again (it's been a while since last time). Now given a list of strings if I want to merge them into one long string (e.g. "scala", "is", "fun" => "scalaisfun" ) I figured one way to do it would be to do a foldRight and apply concatenation on the respective elements. Another way, admittedly much simpler, is to call mkString . I checked on github but couldn't really find the source code for the respective functions (any help on that would be appreciated), so I am not

How can I concatenate forloop.counter to a string in my django template

爷,独闯天下 提交于 2019-11-29 03:08:33
I am already trying to concatenate like this: {% for choice in choice_dict %} {% if choice =='2' %} {% with "mod"|add:forloop.counter|add:".html" as template %} {% include template %} {% endwith %} {% endif %} {% endfor %} but for some reason I am only getting "mod.html" and not the forloop.counter number. Does anyone have any idea what is going on and what I can do to fix this issue? Thanks alot! Your problem is that the forloop.counter is an integer and you are using the add template filter which will behave properly if you pass it all strings or all integers, but not a mix. One way to work

String to variable name in R

喜你入骨 提交于 2019-11-29 02:06:46
I am cleaning a data set and I need to choose the variables depending on another variable. Let's say that if ID = 1 , I need to introduce in the data frame the variable VAR01 , if ID = 2 , I need VAR02 , and so on. Thus, I'm doing a for loop where I paste the variable name 'VAR' with the ID number with the stringf function. The problem is that I need R to understand the string as a function name. I've found in the forum this solution, which doesn't work for me: > variable1 = c("monday", "tuesday", "wednesday") > var_name = "variable1" > eval(parse(text=var_name)) [1] "monday" "tuesday"

MongoDB concatenate strings from two fields into a third field

我的未来我决定 提交于 2019-11-28 23:35:50
How do I concatenate values from two fields and put it into a third one, the values are strings. I've tried this: db.collection.update({"_id" : { $exists : true }}, {$set: {column_2:{$add:['$column_4', '$column_3']}}}, false, true) doesn't seem to work though, throws not ok for storage . I've also tried this: db.collection.update({"_id" : { $exists : true }}, {$set: {column_2:{$add:['a', 'b']}}}, false, true) but even this shows the same error not ok for storage . I want to concatenate only on the mongo server and not in my application. Unfortunately, MongoDB currently does not allow you to

How to store a string var greater than varchar(max)?

▼魔方 西西 提交于 2019-11-28 23:27:09
I'm trying to do this: DECLARE @myVar VARCHAR(MAX) Loop with cursor select @myVar = @myVar + bla bla bla end loop When the loop ends, @myVar is incomplete, containing only 8000 characters. I have tryed to use text, but is not allowed to local vars. What would be a good solution to this case? xml var? I have just looked this posts: How do I pass a string parameter greater than varchar(8000) in SQL Server 2000? Check if concatenating to a varchar(max) will go beyond max allowable characters And others through the web. Regards. Seriously - VARCHAR(MAX) can store up to 2 GB of data - not just 8000

Concatenation of Strings and characters

与世无争的帅哥 提交于 2019-11-28 20:46:45
问题 The following statements, String string = "string"; string = string +((char)65) + 5; System.out.println(string); Produce the output stringA5 . The following however, String string = "string"; string += ((char)65) + 5; System.out.println(string); Produce string70 . Where is the difference? 回答1: You see this behavior as a result of the combination of operator precedence and string conversion. JLS 15.18.1 states: If only one operand expression is of type String, then string conversion (§5.1.11)

Getting unicode string from its code - C#

一笑奈何 提交于 2019-11-28 18:12:10
I know following is the way to use unicode in C# string unicodeString = "\u0D15"; In my situation, I will not get the character code ( 0D15 ) at compile time. I get this from a XML file at runtime. I wonder how do I convert this code to unicode string? I tried the following // will not compile as unrecognized escape sequence string unicodeString = "\u" + codeFromXML; // will compile, but just concatenates u with the string got from XML file. string unicodeString = "\\u" + codeFromXML; How do I handle this situation? Any help would be great! arul You want to use the char.ConvertFromUtf32

Assumed string length input into a Fortran function

限于喜欢 提交于 2019-11-28 14:19:24
I am writing the following simple routine: program scratch character*4 :: word word = 'hell' print *, concat(word) end program scratch function concat(x) character*(*) x concat = x // 'plus stuff' end function concat The program should be taking the string 'hell' and concatenating to it the string 'plus stuff'. I would like the function to be able to take in any length string (I am planning to use the word 'heaven' as well) and concatenate to it the string 'plus stuff'. Currently, when I run this on Visual Studio 2012 I get the following error: Error 1 error #6303: The assignment operation or

Python: Fast and efficient way of writing large text file

≯℡__Kan透↙ 提交于 2019-11-28 13:46:34
I have a speed/efficiency related question about python: I need to write a large number of very large R dataframe-ish files, about 0.5-2 GB sizes. This is basically a large tab-separated table, where each line can contain floats, integers and strings. Normally, I would just put all my data in numpy dataframe and use np.savetxt to save it, but since there are different data types it can't really be put into one array. Therefore I have resorted to simply assembling the lines as strings manually, but this is a tad slow. So far I'm doing: 1) Assemble each line as a string 2) Concatenate all lines