Add content on to the beginning of something (usually a file).
Questions tagged [prepend]
497 questions
12
votes
8 answers
How to prepend to a file (add at the top)
Imagine you have a file
sink("example.txt")
data.frame(a = runif(10), b = runif(10), c = runif(10))
sink()
and would want to add some header information, like
/* created on 31.3.2011 */
/* author */
/* other redundant information */
How would I…

Roman Luštrik
- 69,533
- 24
- 154
- 197
12
votes
1 answer
Is it cheaper to reverse an appended list or to prepend a list? - python
Which is faster and more pythonic?
reverse an appended list
start prepending the list from the start
using deque
E.g. here's ome made-up data to store into a new list
# Let's say my function outputs these output individually.
x =…

alvas
- 115,346
- 109
- 446
- 738
11
votes
2 answers
jQuery append to bottom of list
Can someone lend me a hand
I have this unordered list

Kmack
- 153
- 1
- 2
- 8
11
votes
5 answers
Is it possible to prepend data to an file without rewriting?
I deal with very large binary files ( several GB to multiple TB per file ). These files exist in a legacy format and upgrading requires writing a header to the FRONT of the file. I can create a new file and rewrite the data but sometimes this can…

basszero
- 29,624
- 9
- 57
- 79
8
votes
2 answers
How to prepend to a file in PowerShell?
I'm generating two files, userscript.meta.js and userscript.user.js. I need the output of userscript.meta.js to be placed at the very beginning of userscript.user.js.
Add-Content doesn't seem to accept a parameter to prepend and Get-Content |…

Nato Boram
- 4,083
- 6
- 28
- 58
8
votes
2 answers
How do I prepend a value in an array?
Is it possible to prepend a value to an array? I know how to concatenate two arrays, but if I have an array and a single value (of the same type as the array), can I prepend this element to the array?

Ziva
- 3,181
- 15
- 48
- 80
8
votes
2 answers
How to get next element using JavaScript-only?
Let's say we have this markup:
project.js
…
some project — javascript & html tests
…
user1386320
8
votes
7 answers
In which case it is better to use the .append(), and which .appendTo()?
There is no big difference between those functions except the syntax:
$('.target').append('text');
$('text').appendTo('.target');
As said in jQuery docs:
The .append() and .appendTo() methods perform the same task. The major
difference is in the…

webvitaly
- 4,241
- 8
- 30
- 48
7
votes
3 answers
rails prepend_view_path of mountable engine
In one hand, I have a mountable engine let's say Front
Front contain my assets and couple of pages
It's isolated from MainApp. I don't want it to touch the main app.
In the other hand I want my MainApp using layout and partial of the Front.
So I…

ProxyGear
- 835
- 1
- 10
- 26
7
votes
2 answers
How to override class methods
I want to override the method Selenium::WebDriver.for. This is what I tried:
module SeleniumWebDriverExtension
def self.for(browser, *args)
if browser != :phantomjs
super(browser, *args)
else
options = {
…

ironsand
- 14,329
- 17
- 83
- 176
7
votes
3 answers
Prepending to list python
I have two lists:
a = [1,1,1]
b = [[2,2,2],[3,3,3]]
I want to prepend a on b in one line of code to create:
result = [[1,1,1],[2,2,2],[3,3,3]]
I want to also preserve a and b during the process so you cannot just do:
b[:0] = [a]

Alexander McFarlane
- 10,643
- 9
- 59
- 100
7
votes
8 answers
Unix: prepending a file without a dummy-file?
I do not want:
$ cat file > dummy; $ cat header dummy > file
I want similar to the command below but to the beginning, not to the end:
$ cat header >> file

hhh
- 50,788
- 62
- 179
- 282
7
votes
3 answers
prepend **heredoc** to a file, in bash
I was using:
cat <<<"${MSG}" > outfile
to begin with writing a message to outfile, then further processing goes on,
which appends to that outfile from my awk script.
But now logic has changed in my program, so I'll have to first populate
outfile by…

branquito
- 3,864
- 5
- 35
- 60
7
votes
3 answers
How do I prepend to a stream in Bash?
Suppose I have the following command in bash:
one | two
one runs for a long time producing a stream of output and two performs a quick operation on each line of that stream, but two doesn't work at all unless the first value it reads tells it how…

Paul
- 139,544
- 27
- 275
- 264
6
votes
1 answer
How can I clone, modify, and prepend an element with jQuery?
I want to clone and prepend a div, however I want to change the prepended div name
from preConfi to preConfiXX (eg preConfiA1, preConfiB1) on each iteration. What syntax can I use for this?
/* on initial load, move default template into each…

bob
- 85
- 1
- 2
- 5