Questions tagged [writefile]

It is most often used when someone wants to add/insert content to file programmatically, such as using Javascript function writefile, one can be able to create and write content to a file.

e.g.

const data = new Uint8Array(Buffer.from('Hello Node.js'));
fs.writeFile('message.txt', data, (err) => {
  if (err) throw err;
  console.log('The file has been saved!');
});
380 questions
13
votes
1 answer

fs.writeFile not overwriting file

I am using node-crontab to run the script. fs.writeFile overwrite first time the loop runs but after that is appending data. I have tried deleting the file before writing but is doing the same, deletes it the first time but in the subsequent runs…
Vanessa Torres
  • 169
  • 1
  • 1
  • 9
12
votes
2 answers

Why does WriteFile crash when writing to the standard output?

Here's a "Hello world" program that uses WinAPI's WriteFile (compiled in Microsoft Visual C++ 2008 Express): int _tmain(int argc, _TCHAR* argv[]) { wchar_t str[] = L"Hello world"; HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); if(out &&…
user38329
  • 679
  • 4
  • 17
10
votes
1 answer

writeFile does not create file

Error code looks like: { Error: ENOENT: no such file or directory, open 'sad' errno: -2, code: 'ENOENT', syscall: 'open', path: 'sad' } where 'sad' is the name of file I would like to write to and it doesn't exist. Code looks like…
SubjectX
  • 559
  • 2
  • 6
  • 25
10
votes
4 answers

Writing JSON object to .json file on server

I'm trying to write my JSON object to a .json file on the server. The way I'm doing this now is: JavaScript: function createJsonFile() { var jsonObject = { "metros" : [], "routes" : [] }; // write cities to JSON Object …
Hristo
  • 42,002
  • 60
  • 155
  • 224
9
votes
2 answers

Why does this not run in constant memory?

I am trying to write a very large amount of data to a file in constant memory. import qualified Data.ByteString.Lazy as B {- Creates and writes num grids of dimensions aa x aa -} writeGrids :: Int -> Int -> IO () writeGrids num aa = do rng <-…
Justin Raymond
  • 3,043
  • 2
  • 16
  • 27
7
votes
1 answer

Is WriteFile atomic?

I'm designing a system that will write time series data to a file. The data is blocks of 8 bytes divided into two 4 bytes parts, time and payload. According to MSDN the WriteFile function is atomic (…
ROAR
  • 1,234
  • 1
  • 11
  • 26
6
votes
4 answers

Save Java txt file to folder

First of all - I love you all at Stackoverflow! Everyone is very helpful! Sadly when I go to answer questions they are all too advance for me :'( I want to save the text file to a folder - but not an absolute folder for example I want to save it to…
Rabiani
  • 133
  • 2
  • 4
  • 11
6
votes
1 answer

Write each element of a list on a newline on a text file in Python

Having read this question and this question, I am trying to write each element of a list (mylist) on a newline on a text file (text.txt). So, for example, the list mylist = ['a', 'b', 'ccc', 'dd', 'eeee', 'f', 'ggg'] should be written on the…
user6003691
6
votes
1 answer

Using Pipes to read and write binary data in Haskell

I am trying to read and write very many ints in constant memory. I have figured out how to write the ints to memory but have not figured out how to read them back. import Control.Lens (zoom) import System.IO (IOMode(..), withFile) import…
Justin Raymond
  • 3,043
  • 2
  • 16
  • 27
5
votes
1 answer

problem writing a NSMutableArray to file in cocoa

A real beginners question. I have a NSView subclass in which I create a NSMutableArray containing NSValues. When I want to write the array to a file using writetofile:atomatically: the file is created but it contains none of the NSValues that the…
Luuk
5
votes
1 answer

Create folders dynamically and write csv files to that folders

I would like to read several input files from a folder, perform some transformations,create folders on the fly and write the csv to corresponding folders. The point here is I have the input path which is like "Input…
The Great
  • 3,979
  • 3
  • 11
  • 34
5
votes
1 answer

numpy array2string applied on huge array, skips central values, ( ... in the middle )

I have array of size (3, 3, 19, 19), which I applied flatten to get array of size 3249. I had to write these values to file along with some other data, so I did following to get the array in string. np.array2string(arr.flatten(), separator=', ',…
Brandon Lee
  • 561
  • 6
  • 19
5
votes
1 answer

WriteFile hangs the application when using WaitCommEvent

I am encoutering a issues with win32 programming doing a serial port communication using a event-driven approach. I have my communication handle created as: hComm = CreateFile(lpszCommName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,…
5
votes
2 answers

How to write a only integers numpy 2D array on a txt file

I know how to write the txt file using numpy.savetxt() but I can't get it to write the file using just integers. I have the following code: new_picks = new_picks.astype(int) np.savetxt(fname='newPicksData.txt', X=new_picks.astype(int)) This is how…
Diego Aguado
  • 1,557
  • 15
  • 32
5
votes
4 answers

WriteFile vs TransmitFile for large files that need to be deleted from the server after transfer

I have to trigger user downloads of large files to a webbrowser, where I create the file to transfer on the server, then delete it immediately afterwards. I've found enough examples to see that I should probably use Response.TransmitFile or…
tbischel
  • 5,931
  • 10
  • 47
  • 71
1
2 3
25 26