Questions tagged [file-handling]
file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files
2,693
questions
-1
votes
0
answers
36
views
Need help in upgrading old Turbo C++ code
This is a small portion of an old code I was modifying. Resolved all other errors but stuck here. != operator is using some weird operands and it seems I cannot overload it the right way.
fstream file ...
-2
votes
0
answers
29
views
How to write table of 1-1000 in a file using python with a new column of table coming after previous one in python? [closed]
How can I write a series of table of multiplication in a file using file handling in python, so that each new column is created after the table of previous one reaches 10 multiples?
I have tried a ...
-1
votes
0
answers
13
views
why my code print an extra data at the end of file when that extra data is not in a file i have data on [duplicate]
int main()
{ int count=4;
system("cls");
char name[30],ch;
float marks;
ofstream fout;
fout.open("marks.dat",ios::app);
for (int i = 0; i <...
0
votes
2
answers
31
views
CSV File Handling in Python and calculating values
I am taking an introductory course in Python and am currently discovering how to handle files using Python. I have a CSV file with a few student names, their majors and GPAs
I am trying to handle the ...
-1
votes
2
answers
58
views
Random Characters being stored in a file [closed]
I have created an Admins class with three data members (adminID, adminName, adminPhone) and an array of objects for that same class. The data of each object is to be stored in a .txt file.
There is no ...
0
votes
2
answers
29
views
How do I use a file with numbers on each line as an input (not a .txt file), do some calculations, then write the results into another file in pascal?
I am trying to make a program that will take a file called "root.inp" (file contains 3 integers) as its input, with each integer in a separate line, and then perform the operation shown in ...
0
votes
0
answers
15
views
How to let user write into the file in c++ using put() function?
I'm writing a c++ program to open a file with the user-defined file name. And then using the put() function to let the user write into the file until a newline character is encountered.
But on running ...
-1
votes
0
answers
26
views
Logic for displaying only the Inactive accounts In C File Handling
I have this function that I would only want the inactive accounts to be displayed. What would be the right logic for displaying only the inactive accounts using file handling in C.
I have 2 update ...
-1
votes
1
answer
39
views
Modify/update file based on matching lines from another updated file - python
I have a file that needs to be modified (input.txt):
<sec name="M_14_K40745170" so_fre="mhr17:7907527-7907589" tensi="SGCGSCGSCGS">
<mwan so_fre="mhr17:...
0
votes
1
answer
34
views
Omitting rows that are larger than the specified length in a csv file using pandas
My objective is to read from one csv file and write it to another csv file.
I have a csv file whose header contains x number of columns. Some of the rows have x+1, x+2, x-1 number of values in them(...
-1
votes
1
answer
47
views
how to store additional data in a text file apart from it's content - C++
I am doing this small university project, where I have to create a console-based text editor with some features, and making files password protected is one of them. As I said, it's a university ...
0
votes
0
answers
35
views
Can I declare and open a file in different lines of code, like in this question I need to keep writing once my file is open
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int blocksize = 512;
int main(int argc, char *argv[])
{
if( argc != 2 )
{
printf("mention the file ...
0
votes
1
answer
39
views
How can I create a video streaming server using node.js?
Until now I have only worked with rest-APIs but now I need to create a server which serves several hundred videos of different lengths to client and I have zero experience in video or audio streaming.
...
0
votes
0
answers
16
views
get word from file and make is publipublicly accessible through the program
how can i read word from file and store the word publicly as always programs runs
right now its inisde submit button action performed but i want to get store a random word from file into the check ...
0
votes
1
answer
28
views
How to store contents of string array into 2D array in python and perform operations without any built in function?
I have tried almost everything I cannot figure it out. I cannot figure out which array to use. This is the question and the required output:
0
votes
2
answers
42
views
Why does getline() not read the last int value in the line?
I have a file that contains a list of books. Each book has 4 variables delimitated by a Tab.
The variables are
Title
author
isbn
qty
and there are around 400 book entries.
I have managed to write a ...
0
votes
0
answers
17
views
How to determine the length of a very large file
I am currently working on a filter prototype that works with GNSS data.
The files that I`m supposed to work with are large (with sizes close to 60GB).
Because of this, I am trying to run parallel ...
-1
votes
4
answers
442
views
How write python to Read the first two lines from a text file named "file1.txt" Write the two lines read from "file1.txt" to a new file "file2.txt"
Read the first two lines from a text file named "file1.txt" Write the two lines read from "file1.txt" to a new file "file2.txt"
0
votes
2
answers
31
views
How to print the object itself instead of the location of the object python?
I am making a program that will read lines from a text file which contain the question, the answer and the points awarded which are on lines i, i+1 and i+2 respectively. The lines will be read and ...
1
vote
0
answers
32
views
Why is my Java program creating a new file every time I call append? [duplicate]
I am new to file handling in Java. My input file is a csv file with a number of columns. My objective is to create a new file each time I encounter a different value in the input .csv file and append ...
0
votes
0
answers
18
views
IsADirectoryError in python3 while trying to create a directory if not exist if exist remove and create a main and a sub-directory
import os
import shutil
dest = 'tmp/abc'
try:
if not os.path.exists(dest):
os.makedirs(dest)
else:
shutil.rmtree(dest)
os.makedirs(dest)
except OSError as err:
print(err)
...
-3
votes
1
answer
94
views
Increment file name in C [closed]
I wish to increment the file name as below, and output them as files themselves. So there will be a total of 1000 files in my file directory.
File1.txt,
File2.txt,
…,
File100.txt,
File101.txt,
…,
...
0
votes
0
answers
28
views
What is throughput streams in NodeJS - how is it better to perform operation on throughput stream than on I/O streams
I have come across the terms input and output streams, but what is throughput stream. Sorry if it's a noob question but I couldn't seem to find any reference to it.
I came across this term in event-...
-1
votes
1
answer
41
views
reading multiple files in a directory as python list
I am trying to read multiple files in my directory as python list. The txt files contains list of IDs.
eg., H104.txt
CZ104
Cz509
T3G63
Im sharing the script I wrote,
files = ["H104.txt",&...
0
votes
1
answer
29
views
How we can read the value from file that is .txt file and store it value in ArrayList?
Parse the notepad file data in ArrayList with Records of Student
0
votes
0
answers
96
views
Is there a way to determine if a shared path and a mapped local path are the same?
Let's say I have a file share at \\cloud\MyShare that is mapped to J:\Mason on my computer. If I have two filenames, \\cloud\MyShare\MyFolder\MyFile.dat and J:\Mason\MyFolder\MyFile.dat, is there any ...
0
votes
1
answer
61
views
C++, write from file into map
im just new at c++ and I try to read from a file and write the content into a map<string, float>.
But only the first element of my file gets mapped and i cant figuer out why.
The file looks like ...
0
votes
1
answer
24
views
Create a nested dictionary from a txt file
Hi want to create a nested dictionary from a txt file.
The file looks this way:
BTC 5 42
ETH 0.2 1300
The expected result is this:
crypto = {
"c1" :
{
"name" : "BTC",
...
0
votes
1
answer
77
views
How to save Each index of Array List in text file as new line in java?
I am trying to save each index of list as new line in text file in format below in java and read same as two separate Array List for later . I have done the saving part now i want to read it back into ...
-2
votes
2
answers
55
views
How to I move a directory in python using shutil library?
I'm trying to move a file but it won't work. It keeps giving the error "Errno 2: File or directory does not exist". The code is shown below
import shutil
original = '%userprofile%/Desktop/...
0
votes
2
answers
47
views
I want to fetch double values from a file in C language
I have a numbers.txt file which have some data in this format number0 :23.95 number1 :90.25 number2 :77.31 number3 :27.84 number4 :90.03 number5 :19.83 like this and I want sum of all the floating ...
0
votes
2
answers
47
views
Can we import local csv file data in Django?
i dont to develop a search system in which we are going to import data from csv file which is local file in our computer, i want to import the csv file in django to store it's value in dictionary. but ...
0
votes
0
answers
57
views
How to avoid file corruption in Python?
I have a pretty basic question, perhaps I didn't know the right keywords as I couldn't find a previous answer. I use Python scripts control and gather information for a smarthome environment. I mostly ...
-1
votes
1
answer
41
views
Loop for load multiples files (C++)
I´m trying to load all the files in a folder that have names from the form "file_i.csv".
For this I write the program:
void load_reel_set()
{
bool file_exists = true;
unsigned ...
-1
votes
1
answer
56
views
Why extra 'ÿ' added when writing into a .txt file in C? [duplicate]
I searched about this problem everywhere, but none of the suggested solutions worked for me.
char currentChar;
FILE *fp_read = fopen("../input.txt", "r");
FILE *fp_write = fopen(&...
1
vote
1
answer
47
views
Getting %USERPROFILE% to work in fopen and/or char array C
I have this file that I'm making as a fun personal project that creates a bunch of files called yeet from a short choice of directories
the issue is somewhere between the directory array and the file ...
0
votes
1
answer
35
views
Can I read the last line from txt file when the file's size change? (in python)
I used this:
while (True):
with open('filename.txt') as f:
for line in f:
pass
last_line_char = line[0]
But I want to read when the file's last line or size is change. ...
0
votes
1
answer
45
views
C file-handling program exited without running whole program
I'm using Dev-C++ (we're required to use either Turbo-C++ or Dev-C++). I'm supposed to delete one student (DATA 2) from a student record. Here is the data that we were given:
DATA 1:
2021-10-693
...
0
votes
1
answer
51
views
How to print only the start and endtime from a time log file(txt file) in python 3.8.10
This is the code I am using and I am getting partial output
def main():
with open('time.txt') as f:
linenumber=0
for lines in f:
a=f.readlines()
for i in ...
0
votes
3
answers
51
views
Reading input from command line, separated by whitespace, into array of objects
I am experimenting with reading input from command line and successfully store them in objects attributes.
Example of input (./(nameOfExecutable) < (sourceText) in the command line)
20 5
1 5
28 5
2 ...
1
vote
2
answers
50
views
When there are multiple lines in my file, my code works with out any error but when there's a single line,it fails
My input text file is :-
kiShore,kUMar,bhAvanam
My output file must be:-
Kishore,Kumar,Reddy
...
0
votes
2
answers
56
views
I'm using BufferedReader to input string values into the Excel file but in the next iteration it's skipping the entry of the first string
This is the code I have written. It works fine when I use Scanner but doesn't work properly with BufferedReader.
This is the Question
Develop and test a program according to the following ...
0
votes
0
answers
50
views
python logging file handling
I'm trying to add logging to my app but I'm facing an issue with TimedRotatingFileHandler method. I've made a function with logging config which looks like this ->
def logConfig(moduleName):
...
0
votes
2
answers
62
views
Reading from the file with Scanner.useDelimiter() and hasNextLine() - NoSuchElementException
When I try to load the data from the textfile, with data like this
java;sdf;2.0;3.0;
cpp;sdks;24.6;89.0;
I'm getting the NoSuchElementException with this code.
public void loadFile() {
Scanner scan ...
-1
votes
1
answer
31
views
C File Handling Appending Random Characters into File
The following block of code creates a string
void generateDot(struct node **head, char *str){
if(*head == NULL){
return;
}
else{
struct node *itr = *head;
...
-1
votes
2
answers
49
views
How to assign numbers from a file to variables after reading the file in python?
For example let's say I have two numbers 2 and 3 in a file (data.txt). How to assign those numbers to two variables say a and b while reading the file?
The data.txt has two numbers 2 and 3 in two ...
0
votes
0
answers
14
views
How to display any file(pdf,png,jpg,etc) in webpage uploaded to database via multer
I am working on a project in which I have to upload files to the database I am able to do that and the files are on the MongoDB server as well as in the uploads folder locally. Now the task is that I ...
2
votes
3
answers
56
views
Opening the newest file inside a specific folder
I want the open a txt file.
There is a lot of .txt files in a folder on the desktop and they are always increasing.
I want to open the newest of these txt files.
with open(file=f"C:\\Users\\...
0
votes
0
answers
13
views
what does this mean: started your execution timer at the wrong place?
This is the code for a tool that will convert this JSON-based log to columnar format, i.e., we want to create one file per column. Take Reference to this question from this link: converting json based ...
0
votes
1
answer
51
views
Is using file handling in GUI different from console?
I've been thinking about this for a while but I really can't figure out on how to make file handling work in GUI because as a beginner, I only used console up until now and GUI is pretty messy for me.
...