Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [file]

A block of arbitrary information, or resource for storing information, accessible by the string-based name or path. Files are available to computer programs and are usually based on some kind of persistent storage.

10
votes
3answers
508 views

Explicit song lyrics checker

To stay in practice with my Python I've decided to write an explicit song checker. It checks each word in the song against an array of 14 explicit words contained in the text file. I've decided not to ...
6
votes
1answer
22 views

Updating generated file

With this algorithm I update an automatically generated verilog-file. The update within this file is done by commenting the assigned wires to specific ports of module instances. Is there a better, ...
3
votes
1answer
43 views

Filling A Linked List With Data From File And Handling User Status Messages

I have completed an university assignment on C. While the code is fully functional based on the specifications of the exercise, I like high-quality code and would like to ask for opinions on how can ...
-3
votes
0answers
19 views

changing file name in a prefer sequence format, Python [on hold]

I have a list of file which I have gathered them in time order, I should change the file name (just name) in order of the time. The name changing process will contain; Removing the name from ‘#’ sign ...
11
votes
1answer
160 views

Simple log rotation script

I created a simple script that implements log rotation. It checks the log file size (say, out.log) if it exceeds 5MB limit. If it does then the script copies it to <...
8
votes
2answers
94 views

Read file into vector<byte>

I need to read a range of bytes from a file and return it as a std::vector<std::byte>. My current code looks like this: ...
11
votes
3answers
873 views

Code downloads a text file from a website, saves it to local disk, and then loads it into a list for further processing

My program opens a website and downloads a text file. The text file is a simple file with one word per line. I save the file to local disk and then create a list to hold each line of the text file ...
2
votes
1answer
98 views

Simple program to hide messages in files (steganography)

That is a simple program to hide text messages in text files. I'd like to hear any advices to improve my code and style. Some notes: There is no error handling to simplify the program. It is not a «...
12
votes
2answers
2k views

Average spam confidence

Exercise 7.2 from Python for Informatics: Write a program to prompt for a file name, and then read through the file and look for lines of the form: ...
5
votes
1answer
64 views

Python 3 simple external sort with heapq

I've implemented a minimal external sort of text file using heapq python module. On the few tests I did it seems to works well, but I would like to have some advice to have a cleaner and faster code. ...
3
votes
1answer
42 views

Pidfile single process instance mechanism

I'm writing a system daemon in Rust that may be started by the user manually. Only one instance of the daemon should be running at a time so I have created a pidfile locking mechanism to prevent ...
3
votes
2answers
75 views

3D metrics for segmentation evaluation

I am new to programming and I am trying to develop a machine learning approach for image segmentation (https://en.wikipedia.org/wiki/Image_segmentation) and here I want to evaluate the predicted (...
7
votes
1answer
178 views

Usage of TPL vs Parallel.ForEach() on file processing

i've been working on an implementation of a my own from scratch set of library Astron and I wanted to get my TPL usage reviewed because i'm not confident with this technology :/ My app is currently ...
4
votes
2answers
58 views

Simple INI file parser in Haskell

I've written a rudimentary parser for INI files: ...
5
votes
2answers
322 views

Search string in file, replace it, and write back to file

I have this simple function that just reads a file, replaces all occurances of a string, and write it back to the file: ...
1
vote
0answers
23 views

Ruby exercise in writing and reading a file [closed]

I've been asked to improve the modular decomposition of the main by moving as many lines of code out of main as possible, but i have no idea how i should do this ...
2
votes
0answers
57 views

Game involving finding words containing letters from a memorized list

I wrote this Java game where the user memorizes a list, gets given letters and needs to find a word that contains those letters. The player has only a few seconds to enter the word. Example: Program ...
1
vote
1answer
71 views

Writing billions of lines to text file in java [closed]

I'm trying to write billions of strings lines to a file, it works for up to 40 million lines, but it's throwing out "java.nio.BufferOverflowException" error for 400 million lines. I also think my ...
1
vote
1answer
69 views

Go command-line tool to do some simple byte manipulation

I have some files containing 16-bit words in big-endian order, and a tool to process them that assumes little-endian order. I therefore need to swap the order of each pair of bytes in my files. This ...
1
vote
1answer
36 views

Python functions to save JSON and H5 to local files and S3

I'm trying to copy files to S3 after writing them locally: I have 2 functions which I need to do this. What is the best way to refactor the code that exists in both. ...
4
votes
2answers
75 views

F# wrapper to generate SHA256 signature for a file

I've created the following module to allow me to generate a SHA256 signature for a file. (In real life this is used to verify an image file hasn't been amended). The cut down code looks like this: <...
4
votes
4answers
187 views

Reading a text file that may have embedded nulls

I've always used fgets to read a file. However, I want to read a file that may have embedded \0. I thought of using ...
2
votes
1answer
31 views

Pulling images from Windows 10 Lock Screen to a different folder

Windows 10 has an interesting feature where it will display "fun facts" and images on the lock screen. Occasionally, these images are something I would want to use for a background. These images are ...
4
votes
1answer
34 views

Processing file inclusion directives using mutual recursion

I am preprocessing a set of files where one file is included in another file with an include tag like shown below: file A ...
3
votes
0answers
34 views

Simple one-time pad in Rust

I am new to rust and to start learning the language I decided to implement a simple one-time pad encryption program. The part I am least sure about is the reading and writing from the files. Ideally ...
3
votes
0answers
38 views

Parsing version from Cargo.toml

I want to get version from Cargo.toml and use the value inside my app. Here is a function I wrote: ...
5
votes
1answer
68 views

Two cross-platform implementations of getline in C

I created my cross-platform implementations of getline function in C. It takes different arguments and have different return values than 'original' ...
6
votes
1answer
61 views

Linux cat command in C

I wrote my own implementation of the linux cat command in C for my computer laboratory class. We were asked to replicate its functionality with no options passed as arguments or with just the -b, -n ...
9
votes
2answers
816 views

Read/write a pipe-delimited file line by line with some simple text manipulation

This code that I wrote is supposed to read/write a pipe-delimited file line by line to a new file with some simple text manipulation. (It also adds two new columns) and publishes a "Status Update" ...
-3
votes
1answer
58 views

Code creates huge Text File [closed]

A Java program that writes each digit on a new line, from 1 to max integer. We should end up with 2.4 Billion lines. After looping to near the maximum integer, the text file becomes really huge. Like ...
2
votes
0answers
26 views

Sharing File (Content) without saving it before

I have a listview of PrivateFile objects which contain the fileId (int), fileName (String) ...
3
votes
1answer
80 views

Reading all file contents via x64 assembly

I have come up with the following snippet by building upon the answers given to my StackOverflow question. Just trying to get some other eyeballs to review things so that they can point out any ...
5
votes
1answer
63 views

Sorting words by frequency

I'm doing a simple task in Rust after reading the Rust book: read a text file split it at whitespace sanitize words by removing non-letter characters sort the words by their frequency of occurrence ...
7
votes
2answers
101 views

Multi-Line text reader

I am attempting to teach myself C++ by writing a simple multi-line text reader that reports the lengths of each line. What can I do better now that I have something that "works?" Conventions: ...
3
votes
1answer
43 views

Find a valid english phrase that is identical to what the user entered, save a missing consonant

The Task: The user enters a path to a dictionary file (one word per line) and a phrase as system arguments. My code must then find phrases containing only valid English words, generated by removing ...
5
votes
3answers
114 views

My own getline function for reading strings from files

I am a newbie to C++ and I want to do some cool stuff with it. Here I have implemented my own getline function which reads from a file. so what do you think of this getline function? ...
4
votes
4answers
123 views

Simple command-line XOR encryptor/decryptor for files

I just made this simple XOR encryptor and decryptor. It needs a file with the "private" key string inside. usage: encryptor "file to encrypt/decrypt" "file with the private key" "output file" To ...
2
votes
1answer
41 views

Python code to get all lines between two keyword lines in a file (with exceptions)

I have coded multiple variations on this and would like to make it generic, to avoid coding any more variations. Comments and suggested improvements, please, (typos also), and what about that ToDo ? ...
2
votes
1answer
44 views

Concatenating an already existing filename to create a new file

I had answered this question from stackoverlow and the code below is code that I wrote to explain to the OP a possible way to achieve what I believe they were looking for. The general idea that I ...
10
votes
5answers
2k views

Basic C copy file implementation

I'm a java programmer by trade and starting to learn C/C++. I'd appreciate any pointers on glaring issues with my code style which is acceptable in java but not in C. I feel like open_files is ...
2
votes
1answer
60 views

Locate substrings within a file

Here, I am reading in a newline delimited file that can be millions of repeating lines that looks like this: ...
3
votes
2answers
178 views

Write output file, collating groups of up to 7 input lines

I have this code that reads a file and after processing a few lines writes the output to a second file: ...
3
votes
2answers
44 views

Implementation of getdelim

Note: I wasn't trying to follow the POSIX getdelim signature exactly. I needed to add the consume argument for a project I'm ...
2
votes
1answer
67 views

Finding the longest word without these characters follow-up

Here I asked this question: My goal is to go through the list of all English words (separated by '\n' characters) and find the longest word which doesn't have ...
2
votes
1answer
67 views

Looping through file finding sequences

For an assignment, I had to loop through a text file, and report any positions that a user entered sequence was found. Is there any way I can make this code more efficient, because it seems like I'm ...
3
votes
3answers
235 views

Count characters of a text file

This program counts the number of the occurence of each character that is used in a file. I tried to use everything that Java offers to me properly. If you have tips which library functions would ...
1
vote
2answers
62 views

Reading new data from a constantly updating file in Java

I have a log file which is constantly updated with new lines of data. I need to get new added data in java as soon as it's written. For now my solution is: ...
1
vote
2answers
243 views

Write byte array to end of file

I'm writing a byte array at the end of file. The code works fine, but can you please suggest performance improvements? ...
5
votes
2answers
197 views

Invert rows and columns in an Excel file

Annother little excercise with openpyxl: Say you have a Excel file like this: The Goal is to make make it look like this: My code to acomplish this: inversion.py ...
2
votes
1answer
49 views

Excel blank row inserter

I wrote a program as an excercise, to check the openpyxl module, which inserts blank rows into an excel file. See the docstring in the code for more description. I ...