Questions tagged [append]

To append is to join or add on to the end of something.

Append is an operation usually defined on 1D data structures (e.g., , , , , etc.).
The append operation adds an element to the end of the data structure, consequently, increasing its size by one.

11138 questions
126
votes
7 answers

How to append rows to an R data frame

I have looked around StackOverflow, but I cannot find a solution specific to my problem, which involves appending rows to an R data frame. I am initializing an empty 2-column data frame, as follows. df = data.frame(x = numeric(), y =…
Gyan Veda
  • 6,309
  • 11
  • 41
  • 66
125
votes
6 answers

Adding code to a javascript function programmatically

I'm attempting to customize an existing JS library without modifying the original JS code. This code loads in a few external JS files which I do have access to, and what I'd like to do is change one of the functions contained in the original file…
Munzilla
  • 3,805
  • 5
  • 31
  • 35
124
votes
6 answers

Append text to input field

I need to append some text to an input field...
Kevin Brown
  • 12,602
  • 34
  • 95
  • 155
123
votes
1 answer

Append file contents to the bottom of existing file in Bash

Possible Duplicate: Shell script to append text to each file? How to append output to the end of text file in SHELL Script? I'm trying to work out the best way to insert api details into a pre-existing config. I thought about using sed to insert…
Grimlockz
  • 2,541
  • 7
  • 31
  • 38
122
votes
8 answers

jQuery append() vs appendChild()

Here's some sample code: function addTextNode(){ var newtext = document.createTextNode(" Some text added dynamically. "); var para = document.getElementById("p1"); para.appendChild(newtext); $("#p1").append("HI"); }
user2067567
  • 3,695
  • 15
  • 49
  • 77
116
votes
9 answers

java: use StringBuilder to insert at the beginning

I could only do this with String, for example: String str = ""; for (int i = 0; i < 100; i++) { str = i + str; } Is there a way to achieve this with StringBuilder? Thanks.
user685275
  • 2,097
  • 8
  • 26
  • 32
112
votes
19 answers

JavaScript CSS how to add and remove multiple CSS classes to an element

How can assign multiple css classes to an html element through javascript without using any libraries?
anonymous
  • 2,294
  • 5
  • 23
  • 27
111
votes
10 answers

How to insert table values from one database to another database?

I want a query to insert records from one table to another table in a different database if the destination table already exists, it should append the records at the end of the table.
naveenkumar
  • 1,143
  • 2
  • 8
  • 3
111
votes
10 answers

How to append new data onto a new line

My code looks like this: def storescores(): hs = open("hst.txt","a") hs.write(name) hs.close() so if I run it and enter "Ryan" then run it again and enter "Bob" the file hst.txt looks like RyanBob instead of Ryan Bob How do I fix…
RyanH2796
  • 1,119
  • 2
  • 7
  • 8
104
votes
5 answers

Append multiple pandas data frames at once

I am trying to find some way of appending multiple pandas data frames at once rather than appending them one by one using df.append(df) Let us say there are 5 pandas data frames t1, t2, t3, t4, t5. How do I append them at once? Something…
user3664020
  • 2,980
  • 6
  • 24
  • 45
102
votes
4 answers

How to append binary data to a buffer in node.js

I have a buffer with some binary data: var b = new Buffer ([0x00, 0x01, 0x02]); and I want to append 0x03. How can I append more binary data? I'm searching in the documentation but for appending data it must be a string, if not, an error occurs…
Gabriel Llamas
  • 18,244
  • 26
  • 87
  • 112
100
votes
3 answers

In CoffeeScript how do you append a value to an Array?

What is the prescribed way to append a value to an Array in CoffeeScript? I've checked the PragProg CoffeeScript book but it only discusses creating, slicing and splicing, and iterating, but not appending.
Dave Sag
  • 13,266
  • 14
  • 86
  • 134
96
votes
5 answers

How to check the uniqueness inside a for-loop?

Is there a way to check slices/maps for the presence of a value? I would like to add a value to a slice only if it does not exist in the slice. This works, but it seems verbose. Is there a better way to do this? orgSlice := []int{1, 2, 3} newSlice…
Kyle Finley
  • 11,842
  • 6
  • 43
  • 64
93
votes
4 answers

Python: Concatenate (or clone) a numpy array N times

I want to create an MxN numpy array by cloning a Mx1 ndarray N times. Is there an efficient pythonic way to do that instead of looping? Btw the following way doesn't work for me (X is my Mx1 array) : numpy.concatenate((X, numpy.tile(X,N))) since…
stelios
  • 2,679
  • 5
  • 31
  • 41
93
votes
5 answers

Why does append() always return None in Python?

list = [1, 2, 3] print(list.append(4)) ## WRONG, print does not work, append() returns None ## RIGHT: list.append(4) print(list) ## [1, 2, 3, 4] I'm learning Python and I'm not sure if this problem is specific to the language and how append is…
starcodex
  • 2,198
  • 4
  • 22
  • 34