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

How to check if a file is csv or not?

I have a django views function that converts csv into another delimiter format. But, I just want to convert csv file and reject other files. def index(request): csv_form = '' if request.method == 'POST': csv_form =…
Atom Store
  • 961
  • 1
  • 11
  • 35
0
votes
0 answers

unable to write to a existing text file using c programming

I am writing a program which will update the price of information which is coming from a text file and then display to stdout. The issue I am having is that I will try to read information from the existing text file with information into the…
nixk23213
  • 1
  • 1
0
votes
1 answer

How to create multiple delimited files in python?

I have a program that converts CSV files into pipe delimited files and also counts the total no of lines. But in this case, if the total no of lines is above 7000, I want to create a new output file. The situation would be adjusting just 7000 lines…
Atom Store
  • 961
  • 1
  • 11
  • 35
0
votes
1 answer

for loop in file handling (python)

f = open("food.txt", "r") for line in f: print(line) I don't understand how the above for loop reads the file line by line? Why not character by character or word by word? please explain.
0
votes
1 answer

Error with url.openStream() method when trying to read file from URL

Trying to read a file from URL using URL class and url.openStream(). The code: try { URL url = new URL("http://www.puzzlers.org/pub/wordlists/pocket.txt"); Scanner s = new Scanner(url.openStream()); …
Franco
  • 441
  • 3
  • 18
0
votes
2 answers

How to store an array of strings in a file using C (one string per line)?

I want to store some strings in a text file (one string per line), but on compilation, some unnecessary zeroes get added at the end of each string in the text file. Following is my code :- ** #include #include int main() …
Nova Stark
  • 55
  • 7
0
votes
2 answers

Can we read/write different type child classes of the same parent class to a textfile?

Suppose that I have an abstract class "Vehicle" and 2 other child classes inheriting from the Vehicle class called "Car" and "Bike". So I can create a series of car and bike objects randomly: Vehicle car = new Car(); Vehicle bike = new Bike(); And…
RuFerdZ
  • 46
  • 5
0
votes
0 answers

Adding a file size Management logic ( method) to mange the size of log.txt file we are storing in internal storage of device

We have a log management system that prints out on a file the logcat while the app is running. Each day there’s a new file, and the log file of the day before is deleted. The problem is that if the user uses the app for an extended period of…
0
votes
2 answers

Problem while reading objects from file in c++

I am doing a small college project where I have to add, edit and search records in/from file using OOP concept. Adding into file is working fine but whenever I try to read from file it is printing in unreadable texts. Here is full code and…
Sachin Bhusal
  • 63
  • 2
  • 10
0
votes
1 answer

Can't add items to a csv file because of "PermissionError: [Errno 13] Permission denied:"

I was trying to add some list of words to a CSV file using python file handling, but it was giving a "PermissionError: [Errno 13] Permission denied:" error. The syntax works for a txt file. Although the file was created, no words were added to it. I…
0
votes
2 answers

How to read from file and store in array of objects in c++

I am learning c++ and have a trouble in file handling. I am writing a code as a homework where i have to write objects into a file and then read those objects as array from the file at once. Here is my code: #include #include…
Sachin Bhusal
  • 63
  • 2
  • 10
0
votes
0 answers

Is there any option to open "Ask where to save each file before downloading" of browser using ASP.NET Core 3.1?

While downloading any file from the ASP.NET Core 3.1 application, browser should always ask location where to save it? In the browser we have option namely "Ask where to save each file before downloading" but I want to do it programmatically…
0
votes
1 answer

How to check file content and depending on check condition, prepend or update the the file?

I am very new to Perl and I need to write a Perl script to do the following: Traverse a directory recursively and only process files with a specific extension (e.g .txt). For each .txt files, I need to either prepend a header to the file or update…
Xflkekw
  • 35
  • 2
  • 7
0
votes
1 answer

Proper way to handle file open and file close Exception

Please see this implementation: @staticmethod def read_json_file__(file): reports = [] try: with open(file) as json_file: data = json.load(json_file) for d in data: …
Dan Raz
  • 5
  • 4
0
votes
1 answer

C-Programm reads a file and prints it out, but i get different outputs every time i compile

I have a C-Programm, which reads a .txt-File, saves every float in an array and then is printing out that array. My Problem is that when i run the code sometimes the output is correct and sometimes one number is 0.00 instead of the right number. Its…
chrizzla
  • 53
  • 8