Tag: file-io

53 votes
13 answers
1.7K views
Write lines of text to a file in R

In the R scripting language, how do I write lines of text, e.g. the following two lines Hello World to a fi

avatar
Santiago
0 1 0 9
asked 07 September, 2021
60 votes
17 answers
3.1K views
open() in Python does not create a file if it doesn't exist

What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it

avatar
Benton
0 1 0 9
asked 07 September, 2021
60 votes
10 answers
1.8K views
How to redirect output to a file and stdout

In bash, calling foo would display any output from that command on the stdout. Calling foo > output would

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
57 votes
29 answers
2.4K views
How to find and restore a deleted file in a Git repository

Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some mor

avatar
Hilario
0 1 0 9
asked 07 September, 2021
56 votes
8 answers
2.2K views
How to get all files under a specific directory in MATLAB?

I need to get all those files under D:\dic and loop over them to further process individually. Does MATLAB su

avatar
Scot
0 1 0 9
asked 07 September, 2021
59 votes
12 answers
2.3K views
Read .mat files in Python

Is it possible to read binary MATLAB .mat files in Python? I've seen that SciPy has alleged support for

avatar
Majorie
0 1 0 9
asked 07 September, 2021
55 votes
13 answers
563 views
How to delete a file or folder in Python?

How do I delete a file or folder in Python?

avatar
Boyd
0 1 0 9
asked 07 September, 2021
47 votes
1 answers
1.8K views
C Program can find (via fopen) in gdb but not release (a.out)

Here's a C simple program, that reads a user input for a file location and prints the first line if such

avatar
Wei
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
687 views
How do I create a Java string from the contents of a file?

I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on t

avatar
Vi
0 1 0 9
asked 07 September, 2021