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
90
votes
2 answers

Python RuntimeWarning: overflow encountered in long scalars

I am new to programming. In my latest Python 2.7 project I encountered the following: RuntimeWarning: overflow encountered in long_scalars Could someone please elaborate what this means and what I could do to fix that? The code runs through, but…
timkado
  • 1,922
  • 2
  • 17
  • 27
88
votes
4 answers

Easier way to get a jQuery object from appended element

Is there an easier/quicker way to get the element added using jQuery append: How to get the $selectors element: $container.append('
'); var $selectors = $('.selectors', $container); I tried: var $selectors =…
slolife
  • 19,520
  • 20
  • 78
  • 121
83
votes
2 answers

Python JSON dump / append to .txt with each variable on new line

My code creates a dictionary, which is then stored in a variable. I want to write each dictionary to a JSON file, but I want each dictionary to be on a new line. My dictionary: hostDict = {"key1": "val1", "key2": "val2", "key3": {"sub_key1":…
Victor S
  • 839
  • 1
  • 6
  • 3
78
votes
7 answers

Appending a list to a list of lists in R

I'm having issues appending data to a list which is already in a list format. I have a program which will export results objects during a simulation loop. The data itself is stored as a list of matrices. My idea is to store those lists in a list,…
SJWard
  • 3,629
  • 5
  • 39
  • 54
76
votes
4 answers

Add lines to existing file using Python

I already created a txt file using python with a few lines of text that will be read by a simple program. However, I am having some trouble reopening the file and writing additional lines in the file in a later part of the program. (The lines will…
user1246462
  • 1,228
  • 3
  • 11
  • 20
75
votes
7 answers

Append date to filename in linux

I want add the date next to a filename ("somefile.txt"). For example: somefile_25-11-2009.txt or somefile_25Nov2009.txt or anything to that effect Maybe a script will do or some command in the terminal window. I'm using Linux(Ubuntu). The script or…
sami
  • 867
  • 1
  • 8
  • 13
75
votes
4 answers

Ajax replace instead of append

I used the following jQuery example which works like a charm. However it appends the results. What do I need to change to replace the results instead of appending?
shaiss
  • 2,000
  • 5
  • 22
  • 33
73
votes
5 answers

Append a tuple to a list - what's the difference between two ways?

I wrote my first "Hello World" 4 months ago. Since then, I have been following a Coursera Python course provided by Rice University. I recently worked on a mini-project involving tuples and lists. There is something strange about adding a tuple into…
Skywalker326
  • 1,156
  • 2
  • 11
  • 15
69
votes
5 answers

Ruby - Difference between Array#<< and Array#push

From examining the documentation for Ruby 1.9.3, both Array#<< and Array#push were designed to implement appending an element to the end of the current array. However, there seem to be subtle differences between the two. The one I have encountered…
RavensKrag
  • 895
  • 1
  • 7
  • 9
68
votes
2 answers

Append to the end of a file in C

I'm trying to append the contents of a file myfile.txt to the end of a second file myfile2.txt in c. I can copy the contents, but I can't find a way to append. Here's my code: FILE *pFile; FILE *pFile2; char buffer[256]; pFile=fopen("myfile.txt",…
Sonofblip
  • 1,167
  • 3
  • 12
  • 20
68
votes
7 answers

Unseen factor levels when appending new records with unseen string values to a dataframe, cause Warning and result in NA

I have a dataframe (14.5K rows by 15 columns) containing billing data from 2001 to 2007. I append new 2008 data to it with: alltime <- rbind(alltime,all2008) Unfortunately that generates a warning: > Warning message: In `[<-.factor`(`*tmp*`, ri,…
Farrel
  • 10,244
  • 19
  • 61
  • 99
66
votes
11 answers

Append existing excel sheet with new dataframe using python pandas

I currently have this code. It works perfectly. It loops through excel files in a folder, removes the first 2 rows, then saves them as individual excel files, and it also saves the files in the loop as an appended file. Currently the appended file…
brandog
  • 1,497
  • 5
  • 20
  • 28
66
votes
8 answers

Append text or data to text file in Swift

I already have read Read and write data from text file I need to append the data (a string) to the end of my text file. One obvious way to do it is to read the file from disk and append the string to the end of it and write it back, but it is not…
Ali
  • 18,665
  • 21
  • 103
  • 138
66
votes
5 answers

Appending a dictionary to a list in a loop

I am trying to take a dictionary and append it to a list. The dictionary then changes values and then is appended again in a loop. It seems that every time I do this, all the dictionaries in the list change their values to match the one that was…
Acoop
  • 2,586
  • 2
  • 23
  • 39
64
votes
2 answers

Appending to one list in a list of lists appends to all other lists, too

I'm getting mad with list indexes, and can't explain what I'm doing wrong. I have this piece of code in which I want to create a list of lists, each one containing values of the same circuit parameter (voltage, current etc..) that I'm reading from a…
clabacchio
  • 1,047
  • 1
  • 17
  • 28