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

Writing to file using Python

I have a file called output.txt, which I want to write into from a few functions around the code, some of which are recursive. Problem is, every time I write I need to open the file again and again and then everything I wrote before is deleted. I am…
aviadm71
  • 53
  • 1
  • 9
-2
votes
1 answer

use writefile to write raw usb c++

this is my code : #include #include #include #include #include #include #include #include int main(int argc, CHAR* argv[]) { PVOID data[1024]; DWORD dwBytesRead…
FFF GGG
  • 1
  • 1
-2
votes
1 answer

Three nested Object to file *.txt in C++

i want write an Object to file (*.txt) class MyCircle{ double x; double y; double radius; char index; int check;} class Question{ int index; int quantityOfAnswers; MyCircle [] arrCircles; …
Jetly_93
  • 11
  • 5
-2
votes
1 answer

store Prolog answers to a file

I'm working with ALEPH reasoning engine in SWI-Prolog. I want to save the rules that ALEPH infers and shows them in SWI-Prolog console, but I have no idea how can I do it! The sample result is depicted in the picture below, [Rule 134] [Pos cover =…
Arsham
  • 1
-2
votes
1 answer

WriteFile throws Access Violation when 4th (optional) parameter is NULL

Thought that it may be helpful to someone because it was a kind of surprise for me. WriteFile function tries to write into its 4th (optional) parameter, and if it is NULL it causes Access Violation exception... But not on Windows 8(.1). This is the…
Mar
  • 941
  • 1
  • 10
  • 18
-2
votes
3 answers

Extracting lines from a text in python

I am trying to extract the lines that start with this entries and create a new file. This is what I have: def ReadFileContents(): file_content = open('Testing.pdb') all_file_content = file_content.readlines() list3 = [] for line in…
pedro
  • 9
  • 1
  • 4
-3
votes
1 answer

How read the correct lines from this text file with a python program, and then create a .py file by filling in the data extracted from the .txt file?

Text file to be read (the real one contains more numbers), called number_info.txt veinti tres 23 veinti dos 22 veinti uno 21 veinte 20 tres 3 dos 2 uno 1 This is the code (I need help with this) import re def auto_coding_text_to_number(): …
Matt095
  • 857
  • 3
  • 9
-3
votes
1 answer

How to write double[,] data in C#?

I have a data array double[8,2000000] (4 rows and 2 million columns) and I want to save to file on disk every second. The format is text or BIN. I tried to use streamwriter to write file but it need more than 1 sec. File.write doesn't support the…
Dong Thin
  • 11
  • 1
-3
votes
2 answers

How to write the form information to a local txt archive using javascript/jquery?

I need to write a js function to write the form information into a .txt i will not use database in this project, i will use .txt files to control everything, products, person, employee , etc. All they will be at a .txt called control.txt with the…
-3
votes
1 answer

Precision issues with dlmwrite / dlmread

I recently discovered, quite harshly, that Matlab's dlmread and dlmwrite don't store numerical values at double accuracy. It effects my code, and I need to store big arrays with more precision. A (not) working example : pi1 =…
Amir Sagiv
  • 376
  • 5
  • 23
-4
votes
1 answer

Moving files to multiple destination

I am trying to move files in path folder to multiple destination directory. So my condition is 70 percent of files to move to dest1 and 30 percent to dest2. What i tried so far gives me some error. I am not sure if the logic is wrong or how to do…
user9371612
  • 95
  • 1
  • 12
-5
votes
1 answer

C++ WriteFile doesnt work and returns 5 ( GetLastError() ), even tho i have admin permition

Ok so, im making this programm that lets me access and write in a usb device. Im having this problem that, when i try to run the WriteFile( hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped ); it…
thecner
  • 11
  • 1
  • 1
  • 7
-5
votes
3 answers

How can i rewrite the characters which read from text file to a new text file in c?

I have a file whose name is test.txt. I want to read character by character from the file. Then start writing from "start" to "stop" a new file, its name is main.txt. I tried to code, however it did not run. Please help…
bdllhtlgn
  • 31
  • 7
-6
votes
2 answers

Why file read write functions don't work in Visual Studio Code?

Whenever I try to run this code I keep getting error as shown on the terminal. Please help
1 2 3
32
33