Questions tagged [file-handling]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
52 views

My Python code is not working. output is different from the expected

this is my code: INPUT_FILE = "cs521_3_5_input.txt" with open("cs521_3_5_input.txt", "r") as file: data = file.readlines() students_record_list = [] for i in data: ...
Deepika's user avatar
0 votes
0 answers
8 views

What goes in the fileParts argument of the file constructor in javascript

I'm making a web application with flask, and I've stored an access token as a text file. I want to then read the content of the file from a javascript function. However, the function i saw on This ...
ben's user avatar
  • 11
-2 votes
0 answers
26 views

How to change the standard input and output stream in java for faster testing of test cases for competitive programming [duplicate]

Like we have in c++ we can use freopen("input.txt", "r", stdin) for changing the standard input from keyboard to the the text file input.txt, and freopen("output.txt", &...
Aman Yadav's user avatar
-1 votes
0 answers
30 views

Deleting a row at a particular index in a csv file using CsvHelper in C#

I want to delete second row in a csv file using CsvHelper in C#. I can easily do that by copying entire csv file in a list and then deleting the particular row and then again writing back in that csv. ...
DharuvVerma21's user avatar
0 votes
0 answers
19 views

Need to write OHLC data of stocks real time in a file and read it using another code simultaneously

I am using CsvHelper library in C# to write OHLC Data of stocks real-time in a csv file. Everything is working fine but when I am opening the file to see the data it is giving me an exception stating &...
DharuvVerma21's user avatar
0 votes
1 answer
51 views

Opening an existing text file erases its contents altogether

I am trying to open a text file (it has content). Every time I open it, the content of the file ends up being erased altogether, which I do not want. #include <fstream> #include <iostream> ...
H8FULLY's user avatar
0 votes
0 answers
47 views

Having stack overflow reading a file into a 2D array code 3221225725 [duplicate]

I´m trying a code to read a csv file into a 2D array (from this video https://www.youtube.com/watch?v=Gaq10GBlRJA) The number of columns and rows I´m working with is 4096 (16 777 216 elements), and my ...
Andy Duarte's user avatar
0 votes
0 answers
41 views

Flutter: How to write data from List<String> into a File in Dart

I'm trying to copy all Strings from a List into a File but only a few Strings are being copied. I'm using path_provider pkg from pub.dev to create a file on the User's device. Explored questions ...
bbr's user avatar
  • 50
0 votes
0 answers
43 views

Dart/Flutter: Imports all contacts into .vcf file

I'm trying to copy contacts from an Android device and save them in .vcf format(such as 'Contacts.vcf') on the user's internal storage. Using flutter_contacts: ^1.1.7+1 package, I've accessed and ...
bbr's user avatar
  • 50
-1 votes
1 answer
68 views

access violation during reading data from the file(C++) [duplicate]

I saved some data into the file and when I read all the data at the end of the program right after calling the destructor function I got an access violation error. The data is read successfully but ...
Sgt Mahdi's user avatar
-1 votes
0 answers
51 views

Output 3rd most frequent word

I have a vector filled with words from a file and I have to output the 3rd most frequent word that appears in the file. I cannot use mapping. I keep getting the wrong output, its not outputting the ...
Kameron Benefield's user avatar
1 vote
1 answer
76 views

How to get desired output for the given "G-Man" problem

Context: G-Man is a video game in which G-Man has to move from one point to another on a grid (6 X 6 grid). There could be multiple paths between a source coordinate and destination coordinate and G-...
SHUBHAM's user avatar
  • 17
2 votes
1 answer
67 views

Database file not resetting properly, unless the app is restarted

I'm creating a .NET MAUI Android app which uses a built-in local SQLite database file, CommunityMVVMToolKit simply because it's great and EntityFramework Core for mapping objects into database records ...
MaxKolac's user avatar
-2 votes
2 answers
76 views

How can I remove a pack of data from a file in C++ [closed]

I'm trying to create a to-do list program. I've got a problem removing a task from the txt file, I've tried to read every data from the program and replace that certain data with blank, but in the end,...
Sgt Mahdi's user avatar
-1 votes
1 answer
56 views

Facing error while trying to get access to input file in golang

I am new to golang and in order to complete a coding challenge I have downloaded a code snippet and i have gone through the readme.md file and after running run.bat command as stated in the readme.md ...
SHUBHAM's user avatar
  • 17
-1 votes
1 answer
63 views

How to delete a file? Getting "The process cannot access the file because it is being used by another process" error

Update: I am not getting the error when hosting this online. Able to delete normally. Leaving this up incase there are any useful answers for running locally on windows pc. Context: I download a pdf ...
Rohit's user avatar
  • 139
0 votes
1 answer
39 views

How to edit a particular content in a text file using C?

Following is dummyFile.txt cc:=gcc file:=good src:=$(file).c executable:=$(file).exe $(executable):$(src) $(cc) $(src) -o $(executable) clean: del $(executable) It is a simple kind of ...
Anup Adhikari's user avatar
1 vote
0 answers
34 views

How to efficiently detect and rename downloaded files in Python?

I am working on a Python script to download multiple CSV files from a website and want to rename them as soon as they are fully downloaded. Initially, I used a long waiting period to ensure the ...
Hari Sharma's user avatar
0 votes
1 answer
36 views

Get a list of all videos from the device storage

I am working on Xcode 14. I need help fetching details like URL, duration, thumbnail, and title of all the videos present on the device in iOS. I tried all the approaches available out there. None ...
costomato's user avatar
  • 102
0 votes
1 answer
82 views

Why is the number of words in a text file incorrect in my C program?

I'm trying to count the number of words in a file. I wrote the code below: while ((ch = fgetc(fptr)) != EOF) { if (ch == ' ' || ch == '\n' || ch == '\t' || ch == '\0') { no_of_words = ...
Debbie's user avatar
  • 911
-1 votes
1 answer
59 views

fstream does not save changes C++

I made a program that is supposed to be a simple text editor that can create (if not existed) a .cpp file, read the content of the file and display it on the console, and modify the content and save ...
Zerocool_m12's user avatar
0 votes
0 answers
153 views

VS Code Python- PermissionError: [WinError 32] The process cannot access the file because it is being used by another process

I am new to VS Code, so I appreciate your help and guidance. Here's the issue that I have encountered for days: import numpy as np # linear ...
wafersD's user avatar
0 votes
0 answers
15 views

Storing LinkedList values from a file and showing it to JFrame

I have a question to ask. To cut this short, I have a problem regarding writing the elements to a file and then load it to the JFrame me and my classmates are working with. The simple draft of the ...
Franco Luis Rosel's user avatar
0 votes
2 answers
69 views

Why does this program fail to write the character in the file properly and instead get stuck in an infinite loop?

#include <stdio.h> #include <stdlib.h> int main() { FILE *fp; char ch; fp = fopen("sample.txt", "r+"); if (fp == NULL) { printf("Problem ...
rijulsharma2357's user avatar
0 votes
2 answers
57 views

Free Pascal: Excess characters from previous input is written to the file

I'm working on a program to create a simple database, and I'm encountering a problem starting from the second input. Running result As you can see, I'm experiencing a problem where the second and ...
DonKeehot's user avatar
0 votes
1 answer
102 views

ValueError: Specified a sep and a delimiter; you can only specify one. roster = pd.read_csv(filepath,converters,usecols,index_col=“NetID”)

filepath = “C:/Users/Kunwar Rajeev Singh/Desktop/DAILY PROJECTS/My Python projects/School Grading Pandas Practice/data/roster.csv” converters = {“NetID”:str.lower,“Email Address”:str.lower} usecols = ...
ABHISHEK THAKUR's user avatar
1 vote
2 answers
63 views

Having problem reading a text file in Python

I am trying to read a text file. But it is not printing anything on the screen This simple program works fine. with open("This.txt",'r') as file: for line in file: print(line) output:-...
Nikhil Kumar's user avatar
0 votes
1 answer
64 views

why is it consoling an empty array?

const testFolder = '../assets'; const fs = require('fs'); const array=[] const pattern=/gif/ fs.readdir(testFolder, (err, files) => { files.map(file => { if(file.search(pattern)>0) ...
Lucifer's user avatar
0 votes
0 answers
61 views

fgets() is failing to read data from the fail and leading the program to a halt. The program is stuck there forever

I am opening a file and reading the data from the file using fgets() and this is done every scan. For the first 10 times the data is read correctly but when after a couple of scans fgets() fails to ...
Easha Jilakar's user avatar
0 votes
1 answer
59 views

Reading a binary file using C++

I am performing this simple task of writing into a binary file the contents of a class followed by reading and displaying them. I achieve that using the follwing code: class Matrix{ public: ...
Sourin Dey's user avatar
0 votes
1 answer
86 views

Implicit declaration of function 'getline'

/File Copy: Write a C program to copy a file using file operations/ #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { FILE* fin, *fout; fin = fopen(&...
Suhas Omkar's user avatar
0 votes
3 answers
63 views

Passing Unix Like Path: Why This Java Code Working on Windows Machine

I am confused with a piece of code which is by the way working, but my question is why it is working? Have a look at below code public String GetQuery(int QueryIndex) throws IOException { ...
maddy23285's user avatar
-1 votes
2 answers
30 views

converting the last word of a file into uppercase and writing the new content into a new file in Python

Here is the code I tried! the content in text.txt file is INPUT file=open('text.txt','r') file.seek(0) a=file.read() Lst = a.split() print(Lst) length=len(Lst) print(Lst[length-1].upper()) Lst[length-...
s sanjay's user avatar
0 votes
0 answers
35 views

Why does mmap return an invalid address but not an error code? [duplicate]

In this small program I am attempting to write to a file using mmap. #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #...
EmTor's user avatar
  • 107
-1 votes
1 answer
90 views

File pointer null in c

I am a learning file handling in C. I tried implementing a program but no matter what I do the file pointer is still null. I checked the spelling, the directory, even tried adding and removing .txt ...
Rupa TS's user avatar
  • 19
0 votes
1 answer
58 views

XOR Cipher using native C

I am practicing my C file handling knowledge by coding a program that encrypts-decrypts a file by a given path. The problem is that my program is encrypting the file but never decrypt it. I will share ...
Zerocool_m12's user avatar
0 votes
0 answers
26 views

Python: How to list only sub-directory files in Jupyter Notebook using rglob?

I am writing a script on Jupyter Notebook (Python 3) to execute ipynb files in sub-directories. I am also constrained to be in the Current Directory. *I want to output list of files of .ipynb ...
Piyush Varma's user avatar
0 votes
0 answers
99 views

Menu based python program on Binary file handling using pickle module

import pickle L=[] def write(): f=open("samp1.dat","ab") while True: n=input("enter name:") r=int(input("enter rollno:")) c=...
Rashmi NR's user avatar
0 votes
0 answers
22 views

Create a file and display the words starting with letter given by the user in C [duplicate]

I have written the following code. I am using VS Code. The program is storing the data into the file but it's not displaying the words on the terminal. After entering the EOF command (ctrl+z) nothing ...
Iha Agrawal's user avatar
0 votes
0 answers
100 views

uploading images through php forms in hostinger database?

can we upload images to hostinger hosting database from an php Form and store it in hostinger folder. actually i tried to do so .and i got result while working on localhost but as soon as i hosted it ...
Prasad Kalvikatti's user avatar
1 vote
1 answer
63 views

EOF function proper usage in C

So the following is the code for reversing the inputted data in a file. #include<stdio.h> #include<stdlib.h> #include<string.h> int main(){ int i=0; char ch,str[10]; FILE *ptr; ...
100MIL's user avatar
  • 11
1 vote
2 answers
60 views

How are strings on text file overwritten in Windows C programming?

My "file.txt" looks like this: 1 |My name is Yugal Bishram Don 2 | Here 1 and 2 mean line numbers and not really exist in the file. It means the file contains : My name is Yugal Bishram Don\...
Mildred Gallagher's user avatar
-1 votes
1 answer
54 views

iOS / Swift can not natively decompress a group of files which are .zip. Is there another format, which ios/Swift will do so?

I want to decompress say 5 or 10 files, which have been zipped specifically to one file (although this is not possible with a .zip file, the nature of the question, so it has to be some other format ...
Fattie's user avatar
  • 26.6k
-4 votes
1 answer
58 views

How to pervent mislead in data or dataloss while updating existing file in C programming?

I want to record/update data of a student in "student.dat" binary file. Following is how the struct student looks like: typedef struct student{ int roll; char name[25]; }stu; ...
Mildred Gallagher's user avatar
0 votes
1 answer
20 views

File pointer postion

f=open("hello.txt","r+") f.read(5) f.write("op") f.close() the text file contains the following text: python my world heellll mine According to me after opening the ...
om bahetra's user avatar
0 votes
1 answer
44 views

How to put an arraylist from another class to a 2d arraylist

public void filehandling() throws IOException { FileWriter f = new FileWriter("C:\\Users\\PCB\\Documents\\NetBeansProjects\\Billing\\src\\Files\\MeterNumber.txt"); BufferedWriter b = ...
User123851's user avatar
0 votes
0 answers
29 views

Fortran: Write to the standard out via a variable in a subroutine [duplicate]

I have a complicated Fortran subroutine, which takes the (integer) file handle for a logfile (assumed to be opened and closed outside of the subroutine) as one of its inputs. The subroutine runs a ...
Zim's user avatar
  • 101
4 votes
2 answers
91 views

File pointer position in file handling

f=open("hello.txt","r+") f.read(5) f.write("op") f.close() the text file contains the following text: python my world heellll mine According to me after opening the ...
om bahetra's user avatar
0 votes
0 answers
74 views

I am having a problem writing details for invoice into a text file. The Loop continues again and again

I am writing an invoice for a store in .txt file format and have multiple .py files to handle the volume of main file. Anyway, When the program asks user to input the laptop id, I inputted the id ...
Moon Knight's user avatar
-1 votes
5 answers
83 views

How to write a specific portion in text file using file handling in python?

I am working on a project and want to print multiple lines in a text file. This is the method I used for this purpose. def story_part(file_path,initial_index,final_index): line_number = list(range(...
Ishaan Jangid's user avatar

1
2 3 4 5
59