This tag refers to the process of writing text or data to a file.
Questions tagged [file-writing]
932 questions
-2
votes
1 answer
Python: read line and modify it (if needed)
let's say I have a file Example.txt like this:
alpha_1 = 10
%alpha_2 = 20
Now, I'd like to have a python script which performs these tasks:
If the line containing alpha_1 parameter is not commented (% symbol), to rewrite the line adding %, like…

Rocco B.
- 117
- 1
- 12
-2
votes
1 answer
Reading and Writing to a file Java
today I come to this website with a question. I have searched around the website but cannot find anything remotely close to answering my question.
So I am writing this program which is supposed to have 4 options, 2 of which are to "Read" and…

Joe Glow
- 1
- 3
-2
votes
1 answer
Fast file writing in scala?
So I have a scala program that iterates through a graph and writes out data line by line to a text file. It is essentially an edge list file for use with graphx.
The biggest slow down is actually creating this text file, were talking maybe million…

user3750667
- 25
- 4
-2
votes
1 answer
Validation in PHP form and saving to a file
if($_POST){
$errors = array();
//start validation
if(empty($_POST['email'])){
$errors['email1'] = "Your Email Cannot be empty";
}
if (!filter_var(['email'], FILTER_VALIDATE_EMAIL)){
$errors['email2'] = "Email not…

frag
- 1
- 2
-2
votes
1 answer
Segmentation fault when writing to a file
UPDATED CODE FULLY FUNCTIONAL***
I'm new to C/C++ and I wrote a piece of code that would count the number of times the program has run by writing 'count' to a file each time. Except I'm getting a seg fault error when I try to run it. Anyone can…

Marco Neves
- 141
- 15
-2
votes
2 answers
Creating a text file with the current date and time as the file name in Java
I am trying to create a text file and add some details into it using Java when a button is clicked in my GUI application, the name of the text file has to be the current date and time and the location of the text file has to be relative. Here is the…

Moiz Mansoor Ali
- 23
- 10
-2
votes
1 answer
How do I write a LaTeX file from a list in Haskell?
OK so I have something that looks like this:
[Just [["Value1"],["","",""]],Just [["Value2"],["","","","","","","","","","","","","","","","","","","","","","","","","","","Value3",""]],Just [["Value4","",""]],Just [["Value5"],["","",""]],Just…

BourbonCreams
- 353
- 4
- 21
-2
votes
2 answers
Print nested list elements one after another
I have a list with several nested lists inside like this:
MyMasterListwithListsInside = [List1,List2,List3,List4]
List1 = [f,e,g,t]
List2 = [t,r,e,y]
List3 = [g,k,f,k]
List4 = [o,y,[t,y]]
I am trying to have an output files like that looks like…

K.E.
- 41
- 1
- 5
-2
votes
2 answers
C++ Problems with write array function
I'm trying to write a function that will write an array (2D) to file. This is the code below:
#ifndef WRITE_FUNCTIONS_H_
#define WRITE_FUNCTIONS_H_
#include
#include
#include
using namespace std;
void…

Plinth
- 289
- 1
- 13
-2
votes
1 answer
Optimizing the code to increase performance of the program
I have a program(EOD batch) which processes the daily accrued up accounting positions and updates the UPDT table.
The program is such that.
Query fetches the results from various tables as a result of join etc and stores the records in…

user3346282
- 53
- 1
- 2
- 10
-2
votes
1 answer
Unusual outcome while writing to file
I am having trouble while writing to file using the PrintWriter. Following is my code:
String abc = request.getParameter("textAreaField"); //String is "a b c" (with spaces)
String fileA = dir + "/A";
PrintWriter fileWriterA = new PrintWriter(new…

Hemang
- 390
- 3
- 20
-3
votes
1 answer
I need to write the output to a file and the file needs to look exactly like the output
import time
while True:
for x in range(1, 1000, 1) :
link = ("example.com/" + str(x))
print(link)
time.sleep(0.1)
Here is the code, I need the link variable to be written to a file…

Dead Dog
- 15
- 3
-3
votes
1 answer
File-writing script just creates an empty file named "0"
When I write a file using PHP,

no ai please
- 732
- 3
- 11
- 24
-3
votes
1 answer
I am trying To save file in Windows-1255 Encoding
I am using fs.writefile and I can't save it in ANSI1255.
The file is UTF-8 encoded.
const encodedData = windows1255.encode(doc);
Don't work for me

Sagi
- 3
- 1
-3
votes
1 answer
Cannot write keystroke to Notepad in C++
(C++ 17) I am writing a keylogger that writes the keystrokes onto a notepad but I am having trouble writing to the notepad. I created a function that gets called in a while true loop with a 175ms delay.
std::ofstream…

CrispyNuggets
- 17
- 5