FAQ Database Discussion Community


Python, comparison sublists and making a list

python,comparison,append,sublist
I have a list that contains a lot of sublists. i.e. mylst = [[1, 343, 407, 433, 27], [1, 344, 413, 744, 302], [1, 344, 500, 600, 100], [1, 344, 752, 1114, 363], [1, 345, 755, 922, 168], [2, 345, 188, 1093, 906], [2, 346, 4, 950, 947], [2, 346,...

Beginner Java Task file writer

java,file,append
I am trying to make a java program that appends text into an existing document. This is what it has gotten me at: import java.util.*; import java.io.*; public class Main { public main(String args[]) { System.out.print("Please enter a task: "); Scanner taskInput = new Scanner(System.in); String task = taskInput.next(); System.out.print(task);...

Second append doesn't work on jquery

javascript,jquery,html,css,append
I have a form and need to append a field as many times as required. If the button CLICK TO ADD ANOTHER FIELD is clicked the div should be appended. After the first append (onload), the div responses correctly but from the second one on, I am not getting the...

Pass object to onclick on appended element

javascript,jquery,append
I append several HTML-elements to my DOM and need to pass the object, that's used to create the element, to an onclick-function on the element. I tried the following, but the object references always to the last instead of the current: function addElementToList(obj){ var elementHTML = '<li><a href="#">'; elementHTML +=...

Ruby - How to subtract numbers of two files and save the result in one of them on a specified position?

ruby,file,file-io,append
I have 2 txt files with different strings and numbers in them splitted with ; Now I need to subtract the ((number on position 2 in file1) - (number on position 25 in file2)) = result Now I want to replace the (number on position 2 in file1) with the...

Unexpected list append

python,list,append
import random stats = [] statslist = [] rollslist = [] for var1 in range(4): stats.append(random.randrange(1, 7)) rollslist.append(stats) print(stats) b = min(stats) stats.remove(b) print(sum(stats)) statslist.append(sum(stats)) print(stats) print(rollslist) print(statslist) actual result [5, 1, 1, 3] 9 [5, 1, 3] [[5, 1, 3]] [9] expected result [5, 1, 1, 3] 9 [5,...

Append items to dictionary Python

python,parsing,dictionary,append
I am trying to write a function in python that opens a file and parses it into a dictionary. I am trying to make the first item in the list block the key for each item in the dictionary data. Then each item is supposed to be the rest of...

Appending 0's to make 1MB file with dd

unix,append,dd
I have a binary file abc.bin that is 512 bytes long, and I need to generate 1M (1024 x 1024 = 1048576) byte file by appending 0's (0x00) to the abc.bin. How can I do that with dd utility? For example, abc.bin has 512 bytes of 0x01 ("11 ... 11"),...

Appending to the end of a certain line

python,csv,append
Rather than appending to the end of a file, I am trying to append to the end of a certain line of a .csv file. I want to do this when the user enters an input that matches the first column of the .csv. Here's an example: file=open("class"+classno+".csv", "r+") writer=csv.writer(file)...

Issue pushing item to the end of a PHP array?

php,arrays,append
I have the following code... if ($email_selection == "primary") { $default_select = "<option value=''>Select Email</option>"; $select_1 = "selected"; $to_array[] = $profile_primary_email; } elseif ($email_selection == "secondary") { $default_select = "<option value=''>Select Email</option>"; $select_2 = "selected"; $to_array[] = $profile_primary_email; } elseif ($email_selection == "both") { $default_select = "<option value=''>Select Email</option>"; $select_3...

jQuery append div on click

javascript,jquery,html,append
So I'm making this thing in jQuery where if the user clicks a button a div appears and asks the user to enter some notes(basically a sticky note feature). The HTML and CSS are done correctly, the only problem is that the jQuery won't work: $(document).ready(function() { $("#top-tabs ul li").hover(function()...

Div automatically closing as generated

javascript,jquery,html,dom,append
I have a problem with my div generation, as I generate a form I want to wrap them in a div with same id. But when I inspect the element it's automatically closing before the form. So it doesn't wrap around it as surpose to, it just <div></div> above the...

Appending two strings without str functions

c,string,struct,append
I'm having an issue trying to figure out how to append the char pointer c to the existing Struct String. I want to be able to take in input as such (considering a predefined Struct with the value of stuff being "Hello") append(test,"world") When I try to use strcat and...

Append before last child

javascript,jquery,html,append
I have a div with the ID wrapper, and I am using .append() to insert some content at the end of that div, like this: $("#wrapper").append('<div class="content"><div class="subcontent">Some stuff</div></div>'); However, I also want the option to insert a new child before the last content div in the wrapper. So if...

A bash command that adds newlines to *.cpp and *.h (or any specified filetypes)?

bash,append,echo,newline
I tried running echo "\n" >> *.cpp *.h But I got *.cpp: Ambiguous. A simple command would do, but added bonus if it only adds it to non-empty files that don't end with newline already...

Python: how to simultaneously add two lists to a list?

python,list,append
Let's say I have a list l1 = [] another list l2 = ['a','b'] and two variables u = 1 z = 2 Now I would like to add l2 to l1 and the two variables as a list to l1 as well. One can do it in two steps...

Append contents of each div to textarea

javascript,jquery,html,append
I have a list of divs created server-side, each with a price, quantity (entered by the user) and name. I've managed to use jQuery to calculate the total of each and add those up. What I'd like to do now is to list the name, quantity and total of each...

How do I Append a

javascript,dom,append
This function is run everytime an item is added to an array... It simply creates an "li" element, appends some text to that item... and then appends it to a "ul" element (#requestList)... function UpdateListOnScreen(NewListItem){ var grabList = document.getElementById('requestList'); var text = ""+ GetCalendarName(NewListItem.calChoice) +" For "+ GetLessonSlot(NewListItem.lessonChoice) + "...

Search Google Spreadsheet for same value and append in next column in GAS

google-apps-script,append,spreadsheet,value
I've got a Google Spreadsheet which looks like this: ID | winkelName | 26/05/2015 | 1 | Foo | | 2 | Bar | | 3 | Foo2 | | 4 | Bar2 | | I'm trying to read and write an array of objects with the following structure: history[i].storeName...

String append to JText Area after do other task

java,swing,sockets,append,jtextarea
public void doConnect(){ try{ statusArea.append("Starting server.....\n"); serverSocket = new ServerSocket(5555); statusArea.append("Server started.\n"); statusArea.append("Waiting for client connection....\n"); socket = serverSocket.accept(); statusArea.append("Client connected.\n"); inStream = new ObjectInputStream(socket.getInputStream()); } catch (IOException e){ e.printStackTrace(); } } All strings be appended to text area only after I start server and client connected. So I want...

Why is array empty after appending object to it

ios,arrays,swift,append
I am working in a TableViewController that I am trying to fill up with data from a plist. I declared this at the top: var studentsArray:Array<StudentData>? And now I am doing the following in a function that loads my plist: var path = NSBundle.mainBundle().URLForResource("students", withExtension: "plist") let tmpArray = NSArray(contentsOfURL:...

Clone, append and remove

jquery,append,clone
I have a couple of items as such <div class="item"> <figure> <span class="overlay"></span> <img...> <figcaption> <h3>Title</h3> </figcaption> </figure> </div> I am trying to clone figcaption h3 so that when the item is clicked the figcaption h3 is appended to overlay and when another item is clicked the title of the...

How would I return this interface?

java,append
I am tasked with completing an append method which would return a list interface. A list interface is a class given which basically just has simple methods such as size(), append(), etc. In a new class, I had to write an append method using linked lists, and return a list...

Python List Indexing or Appending?

python,list,indexing,append
What is the best way to add values to a List in terms of processing time, memory usage and just generally what is the best programming option. list = [] for i in anotherArray: list.append(i) or list = range(len(anotherArray)) for i in list: list[i] = anotherArray[i] Considering that anotherArray is...

I want to add a string in between of 2 strings in file, but in output whole text is getting appended at the end of file

python,file-io,append,python-2.6
Code : fo = open("backup.txt", "r") filedata = fo.read() with open("backup.txt", "ab") as file : file.write(filedata[filedata.index('happy'):] + " appending text " + filedata[:filedata.rindex('ending')]) with open("backup.txt", "r") as file : print "In meddival : \n",file.read() Expected Output : I noticed that every now and then I need to Google fopen all...

Appending a data frame with for if and else statements or how do put print in dataframe

r,loops,data.frame,append
How do I put what I printed in a dataframe with a for loop and if else statements? Basically, this code: list<-c("10","20","5") for (j in 1:3){ if (list[j] < 8) print("Greater") else print("Less") }) #[1] "Less" #[1] "Less" #[1] "Greater" Or should it be something more like this? f3 <-...

What is the best solution to appen a line at the beginning of a String variable in Java?

java,string,append
I have the following situation. Into a Java application I have a String variable named *fattura** that contains structured data extracted from an XML...so this fattura variable contains text like this: <FatturaElettronicaBody> <DatiGenerali> <DatiGeneraliDocumento> <TipoDocumento>TD01</TipoDocumento> <Divisa>EUR</Divisa> <Data>2015-03-16</Data> <Numero>004600002117</Numero> <ImportoTotaleDocumento>9.57</ImportoTotaleDocumento> </DatiGeneraliDocumento>...

List appending in Haskell

list,haskell,append,list-comprehension
So I wrote a function that takes a list of lists as an argument and takes every single element from the first list and appends it to a recursively called function on the list of lists' tail, in result returning all possible combinations of selecting elements from these lists. foo...

How do you append values generated at two different point inside the same for loop

python,for-loop,append
I am using the manual method to generate a binary number for the defined value in the sequence for Eg: ([6,4,2,0]). The below code writes the high bit (1) for the position mentioned in the input and writes the low bit for position which is not mentioned in the input....

Python Appending lists [closed]

python,list,random,append
I need to add a randomly selected movie to a list: def rand(): displayList = [] item = print(random.choice(movies_list)) displayList.append(item) print(displayList) But this doesn't seem to add "item" to "displayList" Help??...

Python List To Dictionary - Without Value Overwrite

python,dictionary,key,append,value
Keys = [1,2,3] Values = [["a",1],["b",2],["c",3],["d",1]] Dictionary = dict.fromkeys(Keys) for d in Dictionary: for value in Values: if value[1] == d: # Add to dictionary Dictionary.update({d:value}) # else # Do Nothing print(Dictionary) When I run this piece of code, it works fine until I look closer at the its output....

adding header and append incoming string data into csv python

python,csv,header,append
I received an error message when trying create header and adding incoming data in the next row def copy_real_data(real_curData, real_curTime): real_el_data = open(temp_path, "a") real_prev_data = open(temp_path, "r").read() header = ["Reading Right Shoulder Pitch Data", "ReadingTime"] if real_prev_data =='': real_el_data.write(header) real_el_data.write(','.join([real_curData, real_curTime])) real_el_data.write('\n') real_el_data.close() calling from outside: simulation.copy_real_data(str(0.76575), str(565657.989)) it...

Append a dictionary key to a list depending on the value of the key

python,list,loops,dictionary,append
While iterating in a for loop, I am trying to append a dictionary item's key to a list if the item has a value of 1. What I have is: peeps = {'scoobydoo':0, 'shaggy':0, 'scrappydoo':0, 'velma':1, 'freddy':0, 'daphne':1} ignore_list = [] for peep in peeps: if peep == 1: ignore_list.append(peep)...

Android java append n characters to string

java,android,string,append,string.format
I would like to append "0" string when an int is lower than 5. I have tried this if(allItems_filtered.results(i).min_sale_unit_price.length() < 5){ calc = 5 - allItems_filtered.results(i).min_sale_unit_price.length(); min_sale_unit_price = String.format("%0" + calc + "d", allItems_filtered.results(i).min_sale_unit_price); } int calc is the amount of "0" it has to append in front of the...

Does append work only for the first found element?

jquery,html,append
Does append work only for the first found element? <div id='parent'> <strong> </strong> </div> <div id='parent'> <strong> </strong> </div> $('#parent').append('Text inside div'); I could see Text inside div printed only once when I run the html. PS : This works : $('#parent>strong').append('Text inside div'); It prints the text twice....

send data from ajax to a jquery appendTo?

php,ajax,mysqli,append
I already have implemented an ajax that send a tr and td to a html table every time that a element from the table of the DB is updated, i'll like to send the ajax html data to a append and send it from there to the body and not...

How to append number at the beginning of each line [PHP]?

php,append
I have test.txt with the following data 2015-06-19 14:46:10 10 2015-06-19 14:46:11 20 2015-06-19 14:46:12 30 (this gets auto generated and can not be edited) I then use the following php script to write to a temp file called tempdata.txt <?php $myFile = "filelocation/test.txt"; $myTempFile = "filelocation/tempdata.txt"; $string = file_get_contents($myFile,...

getJSON loading to slow, .toggle() not triggering [duplicate]

javascript,jquery,html,append,getjson
This question already has an answer here: How to return the response from an asynchronous call? 7 answers I don't know how exactly to explain the problem properly so bare with me. Purpose = toggle a section 'more info' for a specific item in a list Problem = a...

Can you append a string and a number as a single entry to a list in python?

python,string,list,integer,append
Is there a way in python 3 to append, to a list, both a string and a number as a single entry. For example if I had a list of class names, and wanted to be able to sort the list alphabetically, I would use: classNames = [] classNames.sort() print(classNames)...

Is there a better way to divide this string into substrings?

java,append,substring,indexof,lastindexof
I am trying to extract the "first_name" and "last_name" from a long string of information that look like this: { "123123123": { "id": "12321312****", "email": "***************", "first_name": "Marcus", "gender": "male", "last_name": "Bengtsson", "link": "https://www.facebook.com/app_scoped_user_id/123123123/", "locale": "en_EN", "middle_name": "Peter", "name": "Marcus Peter Bengtsson" } } The way I do it (which...

Increment through two vectors to add parts of each to a new vector (Matlab)

matlab,loops,vector,while-loop,append
I have two vectors colour and angle. I wish to create a new vector F which is made up as follows: First 16 elements of angle, followed by first 512 elements of colour, followed by second 16 elements of angle, followed by second 512 elements of colour etc... I have...

Jquery click doesn't work on append

jquery,onclick,click,append
I'm trying to use the JQuery .click on a div that i append, but the click doesn't work at all. here is the code, i already tried the help from the other Tutorials i could find on the internet but it didn't work. here is the jquery (very simple version)...

How to append javascript file to the body from javascript file which is in the same directory. Java server faces 2 JSF2

javascript,html,d3.js,append
I have test.js file, it has an initialization function window.onload = function initiliaze() { ... }, which is invoked whenever the window is created. I would like to include other javascript file "d3.min.js" , which is located in the same directory as test.js file is located, into the HTML body...

How to use append correctly without causing HTML Table distortion

javascript,jquery,html,table,append
I have a table which has links rows loaded dynamically from a MySQL database. Currently to provide users quick access to the start of each new letter as in using named anchors, I have the following script which is working just fine in dynamically creating anchors and a small sample...

How to remove object from a array?

javascript,jquery,html5,append
I'm trying to remove object from array, I've tried and don't seem to be getting just right. So would someone be able to look at my code used Code: Array inside files -> [{ "favouriteLinkContent": "Group", "favouriteLinkID": "groupBTNFav" }, { "favouriteLinkContent": "Server", "favouriteLinkID": "serverBTNFav" }, { "favouriteLinkContent": "User", "favouriteLinkID": "userBTNFav"...

Insert numpy array to an empty numpy array

python,arrays,numpy,append
I am trying to create an empty numpy array and then insert newly created arrays into than one. It is important for me not to shape the first numpy array and it has to be empty and then I can be able to add new numpy arrays with different sizes...

How does one rename multiple files using python?

python,file,python-3.x,append,rename
I have lots of programming experience but this is my first python script. I am trying to add the prefix "00" to all the files in a specific folder. First I read the names of all the files and save them in an array. Then I sort through the array...

AWK if length statement append

if-statement,awk,append
I am trying to fix a problem of missing data in a csv file. The column, that should be null, is lacking a double field separator to maintain the csv structure. The example below illustrates what I mean: [email protected]@2/[email protected]@[email protected]@WAW [email protected]@2/[email protected]@[email protected]@JKDes [email protected]@2/[email protected]@[email protected] [email protected]@2/[email protected]@[email protected]@GCCon [email protected]@2/[email protected]@[email protected]@SMAs [email protected]@2/[email protected]@[email protected]@SMAs [email protected]@2/[email protected]@[email protected]@DKo As you can see, in...

jQuery Print elements pushed into array

jquery,arrays,append
I have the following code: var $element1 = $('#selector'), $element2...; var $elements = [ $element1, $element2, $element3 ], $classes = ['class1','class2','class3'], $newElements = []; $.each($elements, function($i, $element){ $newElements.push('<li class="'+ $classes[$i]+'">' + $element +'</li>'); }); $(body).append( $newElements ); The output being: <li class="class1">[object Object]</li> <li class="class2">[object Object]</li> <li class="class3">[object Object]</li> How...

pandas: Convert Series of DataFrames to single DataFrame

python,pandas,append
I have a pandas Series object with each value being a DataFrame. I am trying convert this into a single DataFrame with all of the Series values (individual DataFrame) stacked on top of each other. How can I achieve this without a loop? A toy example below to generate the...

playframework: jQuery: append an element to a list from a view, onclick button from another view

jquery,playframework,append,html-lists
So i have this two views : 1.viewarea.scala.html @(name:String, tags:String, id:String) @Main("Area") { .... <ul id="areaFeat"> //the ul that I want to fill </ul> </div> } 2.areaDescription.scala.html @(id:String) @Main("Description Area"){ <form action="@routes.Application.PostAreaDescription(id)" method="POST"> <textarea cols="40" rows="5" class="form-control" name="textarea"></textarea> <input type="submit" id="postDescArea"> </form> <script> $(document).ready(function(){...

JQuery append() doesn't append

javascript,jquery,html,append
I've got html structure like this: <div id="things"> <div class="whatever"> <div class="frame">content</div> <div class="frame">content</div> <div class="frame">content</div> </div> </div> And I got JS with JQuery script that works on click on button on that page: function intsaver(){ var xmlhttp = new XMLHttpRequest(); xmlhttp.open("POST", "intsaver.php", true); var tosf = $('<div></div>'); $("#things").find(".frame").each(function(){ tosf.append($(this).innerHTML);...

Avoid multiplying of values while appending in object

swift,append
I would like to ask how to corret my issue. I just simply append some "portals" to a depending country. EACH "portal" which comes more than once, I dont want to append. I have following class definitions: class cls_main{ var countries:[cls_country]! init() { countries = [cls_country]() } // "add Country"...

Adding rows per group in pandas / ipython if per group a row is missing

pandas,append
I have a dataframe that contains for each group the number of observations during a certain period. Some groups don't contain all periods, and for these groups I want to append x rows with the missing periods in it. So that each group has a row for all 6 periods...

Appending each directory and files by pandas

python,pandas,append
I'd stacked to append each file using pandas. I have daily directory and each directory has same name file. Here is example. api.log,click.log,id.log are in 20150401 directory. api.log,click.log,id.log are in 20150402 directory. api.log,click.log,id.log are in 20150403 directory. api.log,click.log,id.log are in 20150404 directory. I wanna gather api.log into one dataframe. import...

Appending List to List [duplicate]

java,object,append
This question already has an answer here: Add ArrayList to another ArrayList in java 7 answers I'm writing a class called List which creates an instance variable array of Customers (Customer is just another class that accepts String parameters for a person's name), i.e private Customer[] data I'm trying...

Push / append Angular array data into an HTML element?

arrays,angularjs,append,push
var nameApp = angular.module('nameApp', []); nameApp.controller('NameCtrl', function($scope){ $scope.names = ['do the laundry','buy bananas','do the dishes','mow the lawn']; $scope.addName = function() { // also need to get new date and time stamp it on item $scope.date = new Date(); $scope.names.unshift($scope.enteredName); $scope.enteredName = ""; }; $scope.removeName = function(name){ var i = $scope.names.indexOf(name);...

.on('hover') won't work on appended elements

jquery,hover,append,jquery-events
I'm appending some text onto a div using a button, and want something to happen when you hover over it (after it's been appended). I tried using .on('hover' '.class') but so far haven't been able to get it to work. Any help would be appreciated. Here's an example of what...

Replacing substrings in C without using string library functions

c,string,replace,append
While this code is hideous and I've clearly solved the problem incorrectly, the code works (for the moment). I want to mess around with it, but I truly don't know what I'm doing wrong here. The goal is to, without using any built in functions, take the string "This is...

append(add) a text in url using jQuery

javascript,php,jquery,append
below code working fine but I need to append option1 in href, $(document).ready(function () { $("#head_drop .dd-option").click(function () { var option = $('.dd-option-value',this).attr('value'); var option1 = $('.dd-option-text',this).text(); // alert(option1); $.ajax({ type: 'get', url: '<?php echo $this->getBaseUrl();?>categories/index/city/', data: {option: option}, success: function(data) { $(location).attr('href',"<?php echo $this->getBaseUrl()?>"); } }); }); }); now...

append() or appendTo() for fontawesome

jquery,html,append,appendto
I have this scenario. In title <h2></h2> I want to put fontawesome icon before text. Ex. <h2 id="test"><i class="fa fa-cog"></i> THIS IS TITLE</h2> I will add manual icon for all title, but if any title stay empty (without icon), the script add default icon <i class="fa fa-angle-double-left"></i> I have tried...

Avoid overwriting a text file in R

r,append
I have the following simple R code: sink("output.txt", type=c("output", "message")) cat("Hello", append = TRUE) cat("World", append = TRUE) sink(NULL) It just writes the R console into a text file. I want to put it in an R source file (".r") and run it multiple times. I want to have the...

Create new list by adding the elements of three lists together - associated error (PYTHON)

python,list,append,unpack
I have 3 lists, say: a = [1,2,3,4,5] b = [0,2,4,6,8] c = [2,3,4,5,6] I want to create a new list which adds the respective elements together, i.e. d = [3,7,11,15,19] My code: d = [] for i,j,k in a,b,c: d.append(i+j+k) However, I keep getting the error : ValueError: too...

jQuery - func append , the first one has appear twice

jquery,append
I want to add some details to the tag 'li', so I storage the details into a tag 'a'. But it doesn't work well. The index '0' appears twice. The related code. <div class="frame"> <ul> <li> <a class="thumb" href="#" /> <img title="EOC 450D Camera" src="image/picture1.jpg"/> <a class= "descript" href="test1" />...

Append after focused child

javascript,jquery,html,append
I have a div with the ID wrapper, and I am using .append() to insert some content at the end of that div, like this: $("#wrapper").append('Some divs and input fields'); However, I also want the option to insert a new child after the focused content div in the wrapper. So...

How do I append data to existing clipboard in a new format without removing the existing data?

delphi,append,delphi-xe2,clipboard
I need to put data on the clipboard in several formats, one being RTF. The component I'm using handles everything except for RTF wonderfully. How can I append the RTF format data without blowing away the data placed there already by the ancestor class? I'm trying to avoid duplicating the...

Python list append to list “AttributeError: 'tuple' object has no attribute 'append'”

python,list,split,append,tuples
Alright so I know you cannot append a tuple to a list. However I am still receiving this error despite my best efforts. Can someone tell me what I am doing wrong or what is going on? Traceback (most recent call last): File "C:/Users/.py", line 31, in listRow.append(convertedList) AttributeError: 'tuple'...

Add a form after ul

javascript,jquery,html,append
How i can add form after ul? Here is my code: <article> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione repudiandae possimus dolore perferendis vel magni odio in architecto corrupti consequuntur. <a class="open" href="#">Add comment</a> </article> <ul class="children"> <li>Lorem ipsum dolor sit amet, consectetur.</li> <li>Lorem ipsum.</li> <li>Lorem ipsum dolor...

How to append to DataOutputStream in Java?

java,append,dataoutputstream
I want my program to save URL addresses, one at a time, to a file. These addresses need to be saved in UTF format to ensure they are correct. My problem is that the file is overwritten all the time, instead of appended: DataOutputStream DOS = new DataOutputStream(new FileOutputStream(filen, true));...

How can I modify the MediaRecorder source to allow pause/resume recording

java,android,append,mediarecorder
Is it possible to modify the MediaRecorder source to allow pause/resume recording? I thought modifying this class was not possible, but recently I was told that it was. The question I have is, why would I want to modify MediaRecorder class and just not extend it and then write additional...

User input to store in nested lists with int conversion - Python

python,int,append,nested-lists
I need user input to be stored in a nested list of the form A = [[a, b, c], [d, e, f]]... and so on, based on a number of nested lists that the user desires. a, b, c, ... are integers; so I need to convert the user input...

Python: Appending a 2D list to another 2D list

python,list,append
I am trying to append a 2D list to another 2D list as follows: list1 = [('a', '1'), ('b', '2'), ('c', '3')] list2 = [('d', '4'), ('e', '5'), ('f', '6')] If I append list1 to list2 should output: list2 = [('d', '4'), ('e', '5'), ('f', '6'), ('a', '1'), ('b', '2'),...

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...

Append filename from href without path

jquery,split,append
Thanks for all the replies. There are multiple correct answers, I'm running with Arun's answer because it appears the cleanest solution. Cheers all. The following works as intended... jQuery(document).ready(function(jQuery) { jQuery(".jg-entry").each(function() { jQuery(this).append(jQuery('<h6/>', {text: jQuery(this).parent().find('a').prop('href')})); }); }); ...it appends each 'a' link between h6 tags in a specified div. However,...

Why is concat reformatting my headings?

csv,pandas,append,concat
I have sorted a CSV file as I want it and appended a column to sort my data properly. However, in using concat (I think this is where the issue is, anyway) The output CSV file has been changed to (0L, 'HeadingTitle'). I just want it to be HeadingTitle. import...

Removing div's appended using jQuery append()

javascript,jquery,html,append
Hi i have a button which add's a div to my html using jquery append(). Now each of the div's appended has a close button which removes the appended div using jquery remove(). The code looks like this: $(document).ready(function(){ $("#image-btn").click(function(){ var $imageElement = $("<div class='image_element' id='image-element'><div class='image_holder' align='center'><input type='image' src='{{URL::asset('images/close-icon.png')}}'...

How merge two objects array in angularjs?

javascript,jquery,angularjs,merge,append
I want to append following object array with existing one in angulajs for implementing load more feature. ie,appending AJAX response with existing one each time. I have one variable, $scope.actions which contains following JSON data, { "total": 13, "per_page": 2, "current_page": 1, "last_page": 7, "next_page_url": "http://invoice.local/activities/?page=2", "prev_page_url": null, "from": 1,...

How to fix this AttributeError in Python?

python-3.x,while-loop,append,attributeerror
This is my code: m1=int(input("¿Cuantas filas tiene la matriz 1?: ")) contador_filas1=1 f1=[] while contador_filas1<=m1: print("Dame los valores de la fila",contador_filas1,"(separados por comas):") f1.append=input() contador_filas1=contador_filas1+1 print(filas1) What can I do? If I want to do a list, with the values given by f1.append but when I run the program the...

Why isnt my bash array append working?

arrays,linux,bash,append
This script was working just fine on an AIX box, but now on RH linux box the arrays just dont seem to work. Version on the new RH box is 4.1.2 I declare my array declare -a gridNames=() I get information about a grid gridstats=`snmpwalk -v 2c -c splunk $host...

How to append certain strings with Regex using notepad++

regex,string,append,notepad++
I'm attempting to modify some strings in a json in Notepad++ by adding a new line with some alternate text. For example, the input for one part of the document would be "type": "apples_oranges_one", "attribute": "bananas", "type": "tomatoes_beans_celery", "attribute": "bannanas", and afterwards I would like the result to be "type:...

Python - Find same values in a list and group together a new list

python,list,duplicates,append
I'm stuck figuring this out and wonder if anyone could point me in the right direction... From this list: N = [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5] I'm trying to create: L = [[1],[2,2],[3,3,3],[4,4,4,4],[5,5,5,5,5]] Any value which is found to be the same is grouped into it's own sublist. Here is my attempt so far,...

Append in each line of a .txt file a specific string using Python

python,file,text,append
I have a .txt file with has the following format: /Users/my_user/folder1/myfile.dat /Users/my_user/folder2/myfile.dat /Users/my_user/folder3/myfile.dat . . . so on I want to append in the end of each line another folder path in order to make it look like this: /Users/my_user/folder1/myfile.dat,/Users/my_user/folder1/otherfile.dat /Users/my_user/folder2/myfile.dat,/Users/my_user/folder1/otherfile.dat /Users/my_user/folder3/myfile.dat,/Users/my_user/folder1/otherfile.dat . . . so on Till now I...

Append string to existing textfile in IronScheme

file,scheme,append,r6rs,ironscheme
We are trying to construct a log file using IronScheme, and we have written a code for it using racket. It works fine in racket, but IronScheme throws an error. This is what we have so far: (define write-to-log (lambda(whatToWrite) (with-output-to-file "robot-log.txt" (lambda () (printf (string-append whatToWrite "\r\n" ))) #:exists...

Import xlrd values append to list

python,list,append,xlrd
Forgive the basic question, but I can't find the answer anywhere. I'm trying to import values from an Excel column using xlrd and turn them into a list. Any suggestions? Here's what I have so far, but the list returns all values with "number: 1.0" instead of just 1.0. #...

Python: why is string not appending to every element in the list?

python,string,list,append,output
files = "a.txtb.txt" if files.find( ".txt" ) != -1: files = files.split( ".txt" ) files.remove( "" ) [ file + ".txt" for file in files ] print( files ) I'm new to python. The output I want is the list files = [a.txt, b.txt] in the end, but for testing...

How do I dynamically append text to a Literal Class in asp.net instead of overwriting it?

asp.net,vb.net,text,append,literals
Using asp.net and vb, I am trying to dynamically add names to a Literal Class based on the date associated with the name. I have created two Lists, listDate and listShiftName, with the dates and the associated names respectively. Each name has a date associated with it, but there are...

Append Strings - Performance issue - Java 6

java,string,performance,append,stringbuilder
I need to repeatedly append strings (for about 50 times), which is a substring of another StringBuilder. I need to do this for around 30k inputs. It takes me a time of around 6 minutes. StringBuilder input = new StringBuilder(10000); StringBuilder output = new StringBuilder(10000); //for loop till end of...

JQuery: Create a div as parent and add existing elements to it

jquery,append,add,parent,children
I want to create a new div(row) which contains everytime 4 <a>(incl. the children of <a>) tags and starting before the first <a>tag. Here is how it looks right now: <div class="container" id="cont"> <div class="row"> <div class="col-lg-12"> <h1 class="page-header">My Page Header</h1> </div> </div> <a>....</a> <a>....</a> <a>....</a> <a>....</a> <a>....</a> <a>....</a> <a>....</a>...

Append Loop Variable to Variable Name

c#,string,for-loop,iterator,append
I have 5 DataTables that needs to be converted to TXT files. Instead of creating them separately, I thought I use a for loop. Here's my code: StringBuilder sb = new StringBuilder(); for (int i = 1; i < 5; i++) { DataTable dtFile1 = file1BLO.SelectFile1ForCSV() foreach (DataRow dr in...

How to append single quotes into both side of stringBuilder object in java

java,string,append,stringbuilder
I would like to add single quotes into an array of string. If I has 5 values.(1,2,3,4,5). I need like this '1','2','3','4','5' I have tried some like below but I am getting error public class Main() { StringBuilder values=new StringBuilder(); values=getValues(1); System.out.println(values.toString()); public StringBuilder getValues(int productid){ StringBuilder Variable_1=new StringBuilder(); Variable_1=get(productid);...

Check if variable have already been appended

jquery,if-statement,append
Got a problem. In the following fiddle I have tried to exemplify how I wish to check for if the variable "htmlstring" has already been appended, and if so, then not to append another. On the other hand if it haven't been appended, ofcourse append it. http://jsfiddle.net/Lc5gdvge/6/ How do I...

Python, add data to file on server how?

python,append,ftplib
I'm appending values to a log file every 6th second. Every 30 sec I'm transferring this log to a server as a file. But instead of transfering the whole file, I just want to append the collected data to the file on my server. I haven't been able to figure...

Python: Write array values into file

python,arrays,file,append
I'm coding a python project that involves me reading a file and filling an array with the integer values in the file, doing a whole crazy none important process (tic tac toe game) and then at the end, adding a number (wins) to the array and print it back out...

How to add class to
  • located within a .html() variable?
  • jquery,append
    I have a variable from where I save the HTML of a certain div: var menu = $(".menu").html(); The saved html() = var menu looks as followed: <li> <a href="#">item 1</a> </li> <li> <a href="#">item 2</a> </li> The two <li>'s are then copied over to another div otherDiv.append(menu); The issue:...

    new dictionary from existing dictionary values

    python,dictionary,key,append,value
    I am trying to figure out how to perform the following: firstDictionary = {"firstKey" : "A", "secondKey" : "B"} secondDictionary = {"firstKey" : 3, "secondKey" : 47} emptyDictionary = {} for key, value in firstDictionary, secondDictionary: # emptyDictionary = some sort of append method... so that secondDictionary = {"A" :...

    In Python is there any way to append behind?

    python,matrix,append,behind
    I have a matrix: [[1 2 3], [4 5 6], [7 8 9]] and I need to create a new matrix: [[7 4 1], [8 5 2], [9 6 3]] I tried new_matrix = [[1]] new_matrix.append(matrix[1][0]) and got a new_matrix = [4 1] instead of a new_matrix = [1 4]...

    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 +...

    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...

    jQuery append delay

    javascript,jquery,append,delay
    Can someone explain why the rows in the console are appending all in one time? I want them to get append one by one. row is an array of strings in the program and here is the code: var dodajRed = function(redenBroj) { setTimeout(function() { $('.console').append('<p>' + row[redenBroj] + '</p>');...

    Deleting a range of items in a list versus printing a range of items in a list

    python,list,printing,delete,append
    Observe the code below: 1 names = ['Louisa', 'Mean Girl Star Wars Fan', 'Olive'] 2 names.append('Stephen') 3 names.append('Lucia') 4 names.append('Gianna') 5 names.append('Sal') 6 names.append('Andrew') 7 names.append('Francesca...we think') 8 names.append('Peter or John') 9 del names[0:3] 10 print(names[0:6]) Why is it that I must specify a range of [0:3] to delete the...