Questions tagged [file-handling]

file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files

2915 questions
0
votes
2 answers

This code snippet is working the first while loop but is not executing the one after it

This code is supposed to skip a line of file and write everything else in a different file, delete the original one, and rename the different one to the one deleted. Whats wrong with this code is its not working after the first file ,i.e., the…
user13695064
0
votes
1 answer

Why is this code skipping the first character and printing a special character at the end of the file

ch = getc(lname); while (ch != EOF) { ch = getc(lname); if (ch == '\n') temp++; //except the line to be deleted if (temp != delete_line) { //copy all lines in file replica.c putc(ch, rep); } } I have…
user13695064
0
votes
2 answers

How to Overwite a string choosen line in 2 Column list in the file using Python?

How to Overwite a line in file using python? this is my list in text file "Sample" , "S" "Simple" , "T" "test" , "S" how to Overwite the second line? "Simple", "T" into "Simple", "S" then the text file will be change like this: "Sample" ,…
Newbieee
  • 167
  • 10
0
votes
1 answer

Synchronize File Server and Database Backups?

I'm currently building a backend application that will need to store and serve a lot of images and videos (> 1 Mio. each). The files will obviously get uploaded and sometimes deleted but not updated. I did some reading on the issue of whether to…
0
votes
1 answer

Why am I unable to write float and integer values to Binary File c++?

This is the code snippet, wherein "s" is a array of class objects. for(int i =0; i<4; i++) { cout<<"Student "<>regno; cout<<"Enter name: "; cin>>name; …
ChaoS Adm
  • 715
  • 1
  • 5
  • 12
0
votes
1 answer

My files get deleted when moving content from the first file ("constituencies") to the second ("temp") and renaming it after

/* I want to transfer the content from the first file ("constituencies") to the second ("temp") and then delete the original ("constituencies") file then rename() ("temp") to ("constituencies") so it can be refreshed with a specific entry/line be…
0
votes
1 answer

Using multiproccessing for displaying realtime output from Subproccess while writing the output to file

I have a code that takes the host address, asks for filename (to save on user's desktop) and asks if user's want to clear the file or append to it. when it runs, it prints the output to screen first and then writes the file. how can I use…
0
votes
2 answers

Why is my code working fine when running in the console but not when used in the script?

When I tried the following code in my IDE and in the command prompt with python test.py, my text file was still empty afterward: with open("test.txt", "r+") as file: file.write("Hello World") I was confused, because this worked before. So I…
El Fuerst
  • 73
  • 6
0
votes
2 answers

CSV reading with Python

I have about 20 rows of data with 4 columns each. How do I print only a certain row. Like for instance print only Row 15, Row 16 and Row 17. When I try row[0] it only prints out the first column but not the entire row. I am confused here. Right…
user11516820
0
votes
1 answer

readline() code in my python app works not correctly. Why?

I am building an app by python3.8.3 and pyqt5. This is a part of my code: def logupd(self): users=open('NeveshtarUsers.txt', 'w') users.write('Username: ') users.write(self.user2.text()) users.write(' Password: ') …
F. Basiri
  • 1
  • 2
0
votes
2 answers

Cannot create and open File using file handling

I am writing a basic code but run into an error when trying to open a file. I've had a rough break and am having to start from the basics. Following is the part of the code where I run into the error: int main() { string name; fstream file;…
Temp Estcrowd
  • 73
  • 1
  • 5
0
votes
1 answer

How to create a function to read from a text file in C++ and ignore certain character and store data values in appropriate variables?

I have the class date defined as follows. I have programed the function write(ostream &o) to write the date in this format 27/May/2020 so its easily readable to the user. Now i want to read from a file containing the date in aforementioned format.…
0
votes
2 answers

Python Flask File upload

This is the code I have written in python flask to upload a excel file : from flask import Flask,render_template,request import csv app=Flask(__name__,template_folder="/Users/viru/Downloads/Login_v5") …
viruchith
  • 51
  • 1
  • 8
0
votes
2 answers

Using this pointer to write object to binary file in c++

void Employee::store_data(string filename) { fstream file; file.open(filename,ios::app | ios::binary); if (file) { file.write((char*)&this,sizeof(this)); file.close(); } else cout<<"\n Error in Opening the…
0
votes
1 answer

Write lines to files every 100 lines

Here is my code which reads 0.2 million lines from file. The line which contain correct URL code write it into true.txt and line which contain wrong URL code write it into wrong.txt. The code writes in these files when it read all lines. I want to…
1 2 3
99
100