file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files
Questions tagged [file-handling]
2915 questions
12
votes
3 answers
file.close() exception handling inside a with statement in Python
I know that in Python the file.close() method doesn't have any return value, but I can't find any information on whether in some cases it throws an exception. If it doesn't do that either, then I guess the second part of this question is…

MattyZ
- 1,541
- 4
- 24
- 41
11
votes
3 answers
Reading a string from file c++
I'm trying to make billing system for my father's restaurant just for practice. The problem is that the program doesn't read the complete string one time.e.g If there were "Chicken burger" in txt file then the compiler reads them but break them into…

user3139551
- 161
- 1
- 1
- 9
10
votes
2 answers
Unsupported operand type(s) for +: 'WindowsPath' and 'str'
The code I'm working on throws the error Unsupported operand type(s) for +: 'WindowsPath' and 'str'. I have tried many things, and none have fixed this (aside from removing the line with the error, but that's not helpful).
For context, this script…

Moonaliss
- 103
- 1
- 1
- 6
10
votes
2 answers
Reading assets or raw or resource files as a File object in Android
I have a jar file for which i need to pass file object. How can i pass resource or assets to that method as a file object?
How to convert assets or raw files in the project folders in to file objects ?

Pavandroid
- 1,586
- 2
- 15
- 30
9
votes
3 answers
Performance using STDOUT (screen) vs regular file
I have been doing some research and I got this situation. If you want to write to the STDOUT (screen), you won't be able to do a multithread script which prints the data faster tan a simple single thread script. But, if you write to a file like…

Iván Rodríguez Torres
- 4,293
- 3
- 31
- 47
8
votes
1 answer
OSError: [Errno 24] Too many open files; in python; difficult to debug
I am running code which after sometimes hours, sometimes minutes fails with the error
OSError: [Errno 24] Too many open files
And I have real trouble debugging this. The error itself is always triggered by the marked line in the code snippet…

carl
- 4,216
- 9
- 55
- 103
8
votes
1 answer
Why does PHP think it's writing to a file but it isn't?
I've got an HTML form that has a PHP pgm to write the results to a file. I've basically copied it from The Web. It's not rocket surgery. It's running with PHP 7 on a Raspberry Pi with the most recent Raspbian. The PHP pgm reports that the file…

Roger Sinasohn
- 483
- 4
- 11
8
votes
2 answers
Read from file and write to another python
I have a file with contents as given below,
to-56 Olive 850.00 10 10
to-78 Sauce 950.00 25 20
to-65 Green 100.00 6 10
If the 4th column of data is less than or equal to the 5th column, the data should be written to a second file.
I tried…

Upeka Fernando
- 85
- 1
- 1
- 6
8
votes
2 answers
How can I get last modified timestamp in Lua
I am trying to work on Lua file handling. I am able to open (read), write and close the file via:
local session_debug = io.open("/root/session_debug.txt", "a")
session_debug:write("Some text\n")
session_debug:close()
How can I find the timestamp of…

Haswell
- 1,573
- 1
- 18
- 45
8
votes
1 answer
Prefer BytesIO or bytes for internal interface in Python?
I'm trying to decide on the best internal interface to use in my code, specifically around how to handle file contents. Really, the file contents are just binary data, so bytes is sufficient to represent them.
I'm storing files in different remote…

Aidan Kane
- 3,856
- 2
- 25
- 28
8
votes
3 answers
modify existing contents of file in c
int main()
{
FILE *ft;
char ch;
ft=fopen("abc.txt","r+");
if(ft==NULL)
{
printf("can not open target file\n");
exit(1);
}
while(1)
{
ch=fgetc(ft);
if(ch==EOF)
{
…

zee
- 188
- 2
- 2
- 9
8
votes
3 answers
java: how to use bufferedreader to read specific line
Lets say I have a text file called: data.txt (contains 2000 lines)
How do I read given specific line from: 500-1500 and then 1500-2000
and display the output of specific line?
this code will read whole files (2000 line)
public static String…

Redbox
- 1,457
- 5
- 17
- 22
8
votes
3 answers
Read created last modified time-stamp of a file using C#
Possible Duplicate:
How to get Modified date from file in c#
How do you, Read created / last modified time-stamp of a file, using C#?

Abhijeet
- 13,562
- 26
- 94
- 175
7
votes
2 answers
Parsing binary data in JavaScript
I want to design and write a 3d image viewing web application in JavaScript. I've already written it in java and flash and basically want to port it. I want the 3d image export files to be in a binary format just like the Java and flash versions…

Zeeno
- 2,671
- 9
- 37
- 60
7
votes
2 answers
Dump a sparse matrix into a file
I have a scipy.sparse.csr matrix and would like to dump it to a CSV file. Is there a way to preserve the sparsity of the matrix and write it to a CSV?

Dexter
- 11,311
- 11
- 45
- 61