Questions tagged [writefile]

For questions about writing to a file. It could be referencing appending data, rewriting all existing content, or other related uses of functions that programmatically edit files. It is not limited to a certain language.

This tag is most often used when someone wants to add/insert content to a file programmatically. One example is in the Node JS function fs.writeFile, which is used to create files and write to them.

This is an example script which shows the usage of fs.writeFile to write a string to message.txt.

// Node JS

const fs = require('fs');
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!');
});

Make sure to pair this tag with a language tag as is generally not specific enough to describe a complete question.

494 questions
1
vote
4 answers

Writing nested list into csv by column

I have a list of lists looks like this: signals_list = [ [1,4,7..... 5,7],[4,-7,1....-5,-8,4],.....] I want to write these inner lists column wise in a csv file. I have 176 inner lists and 176 column needs to be made. Every inner list has almost…
Noman marwat
  • 353
  • 1
  • 18
1
vote
3 answers

is it legal to pass STD_OUTPUT_HANDLE directly as input HANDLE to WriteFile?

The WinApi WriteFile() function seems to accept the STD_xxx_HANDLE constants directly as a first argument. I executed the following: #include main() { DWORD bw; WriteFile( (void *)STD_OUTPUT_HANDLE, "output", 6, &bw,…
Paul Houle
  • 735
  • 9
  • 17
1
vote
1 answer

How to increment last number in file python

I have below text in the file firefox-x 46.0: google 5.1.0.1: - request - branch I need to extract the last letter of first line and increase by one version and append to same file. My append part will be firefox-x 46.1: google…
user1464878
1
vote
1 answer

Trying to write to a json file using Node fs.writeFile

I hope I'm saying this correctly. What I'm trying to do is write to a json file using fs.writeFile. I can get it to work using the command line but what I want to do is call a function maybe a button click to update the json file. I figure I…
ifelse
  • 299
  • 2
  • 8
  • 19
1
vote
1 answer

Trouble copying a column to a file using Pandas

The goal of the code is simply to do the OHE in two columns and write the rest of the columns as they are in the original file. But the column Dur, as shown in the image, is somehow "bugging" when it's written in the second file and passing more…
1
vote
1 answer

How do I write an object to a file and read it back without using json and pickling in python?

I created a class called Hand and an object h1. I wrote the result of my object in a file (handtest.txt) with the code: h1 = Hand(3) datafile = open('handtest.txt', 'w') datafile.write(str(h1)) datafile.close() I want to read what's in the file…
1
vote
2 answers

"ReadFile Function" is there a way that I can no longer declare specific number of bytes to be read?

I'm trying to make a program using windows API in C++ The goal is to read the content of the text file that I've created and able to manipulate the content using bitwise XOR (change to lowercase and uppercase, vice versa) then put the manipulated…
nwb1027
  • 29
  • 3
1
vote
1 answer

Node.js - How to write/serialize an arbitrary JavaScript object that contains functions and special values and save it to a .js file

I have a JavaScript object that contains functions and special values like Infinity, as well as strings and numbers: const myObject = { propertyA: "my string", propertyB: 5, propertyC: () => "function returing a string", propertyD:…
JoG
  • 962
  • 2
  • 11
  • 17
1
vote
0 answers

Automatically get UAC prompt when trying to write to protected directory?

In Windows 7 x64 SP1, I get this error: EInOutError: Cannot create file "C:\Users\Public\Desktop\test.txt". Access denied. ...when I run the following program: program TestConsoleApplication; {$APPTYPE CONSOLE} {$R *.res} uses …
user1580348
  • 5,721
  • 4
  • 43
  • 105
1
vote
1 answer

Windows WriteFile blocks even with FILE_FLAG_OVERLAPPED

I have the following code that creates a file using CreateFile with the FILE_FLAG_OVERLAPPED flag, and then calls WriteFile 100 times in a loop, passing in an OVERLAPPED structure uint64_t GetPreciseTickCount() { FILETIME fileTime; …
tcb
  • 4,408
  • 5
  • 34
  • 51
1
vote
0 answers

C++ Writing resources to disk

I don't know what i'm doing wrong.. the code is creating a empty file. resource.h #define IDR_RCDATA1 101 resource.rc IDR_RCDATA1 RCDATA "A.exe" main.cpp #include "resource.h" #include using namespace std; int main() { HINSTANCE…
Siewdass Sf
  • 169
  • 1
  • 10
1
vote
1 answer

Chrome extension - using the filesystem API

The filesystem API cannot be used by unpacked extensions, which is awfully great for development. But then the real surprise came when I realized I can't use it also with my extension packed, because Chrome tells me it cannot find it in the store…
1
vote
0 answers

Strange output when using PrintWriter

So, I just started using Java for coding today and I am trying to print a String and an Integer to a text file. Here is my shortened code. First I get a user input with the help of a Scanner sc. This user input is my name string which is added to…
1
vote
0 answers

loop through barcodes canvas to create buffer and write to file

I'm having some troubles wrapping my head around a way to solve this problem ive been having with some basic code. This is just testing some functionality for a bigger project, and i am trying to find a way to have a function that accepts an array…
Miles
  • 11
  • 2
1
vote
1 answer

c++ adding text variables with WriteFile errors

my problem is that when I use this: LPSTR a = "0"; LPSTR b = "1"; LPSTR c = "2"; LPSTR d = "3"; LPSTR e = "4"; TCHAR strex[5]; DWORD x; myFile = CreateFile("C:\\a.txt", FILE_WRITE_DATA, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,…
Dav3
  • 19
  • 4