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.

Filter by
Sorted by
Tagged with
2 votes
0 answers
95 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 ...
Paul Lemarchand's user avatar
1 vote
1 answer
1k 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 ...
Hither Joe's user avatar
1 vote
1 answer
112 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 ...
user200783's user avatar
1 vote
1 answer
444 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. ...
gogasca's user avatar
  • 601
4 votes
2 answers
597 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: <...
Jackson's user avatar
  • 507
4 votes
4 answers
715 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 ...
Neil's user avatar
  • 1,050
2 votes
1 answer
56 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 ...
Der Kommissar's user avatar
4 votes
1 answer
54 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 ...
Hari Krishnan's user avatar
3 votes
0 answers
227 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 ...
carloabelli's user avatar
3 votes
0 answers
294 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: ...
philipjkim's user avatar
5 votes
1 answer
301 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' ...
DeBos's user avatar
  • 525
6 votes
1 answer
3k 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 ...
userUSeruser's user avatar
10 votes
2 answers
9k 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" ...
Emily Alden's user avatar
-3 votes
1 answer
70 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 ...
king amada's user avatar
2 votes
0 answers
59 views

Sharing File (Content) without saving it before

I have a listview of PrivateFile objects which contain the fileId (int), fileName (String) ...
Lebron11's user avatar
  • 143
3 votes
1 answer
3k 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 ...
Kittoes0124's user avatar
  • 1,940
6 votes
1 answer
97 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 ...
jtbandes's user avatar
  • 262
7 votes
2 answers
592 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: ...
Kittoes0124's user avatar
  • 1,940
3 votes
1 answer
54 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 ...
Resthier's user avatar
5 votes
3 answers
1k 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? ...
ar4n m3t's user avatar
4 votes
4 answers
2k 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 ...
Vital Zero's user avatar
3 votes
1 answer
2k 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 ? I ...
Mawg says reinstate Monica's user avatar
3 votes
1 answer
76 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 ...
Francis Cugler's user avatar
10 votes
5 answers
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 ...
LiamRyan's user avatar
  • 313
2 votes
1 answer
73 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: ...
The Nightman's user avatar
3 votes
2 answers
356 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: ...
Farzad Vertigo's user avatar
3 votes
2 answers
167 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 ...
Chris Frank's user avatar
2 votes
1 answer
98 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 ...
Aykhan Hagverdili's user avatar
2 votes
1 answer
90 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 ...
Linny's user avatar
  • 9,989
3 votes
3 answers
1k 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 ...
user avatar
1 vote
2 answers
3k 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: ...
Arthur's user avatar
  • 111
1 vote
2 answers
4k 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? ...
user3145350's user avatar
8 votes
3 answers
6k 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 ...
Sandro4912's user avatar
  • 3,046
3 votes
1 answer
2k 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 ...
Sandro4912's user avatar
  • 3,046
1 vote
1 answer
2k views

Java splitting too large text file enhance performance

I have a too large data.txt file containing data as follows: ...
Khaled's user avatar
  • 309
5 votes
1 answer
177 views

Find big files on the harddrive

For practicing Python I wrote a script which scans the harddrive for large files and lists them in a report. The script takes the root path and then all the subfolders are scanned aswell. Also the ...
Sandro4912's user avatar
  • 3,046
3 votes
1 answer
2k views

Mad Libs excercise

I did the following Excercise from Automate the boring stuff with Python Chapter 8: Create a Mad Libs program that reads in text files and lets the user add their own text anywhere the word ...
Sandro4912's user avatar
  • 3,046
6 votes
2 answers
452 views

Text Duplicate filter in Python 3.7

I wrote this program just to remove duplicates from wordlist used for brute-force, but it can be used for every txt file i guess. It is a pretty long program for what it does, and I'm sure there is a ...
Thewizy's user avatar
  • 319
6 votes
2 answers
243 views

Minimalistic, self-contained class for reading a sectionless INI file

When sections are ignored and no writing capability is needed, an INI reader becomes quite simple to implement. Here is my attempt at reading a sectionless INI file without any non-...
Sparkler's user avatar
  • 309
2 votes
1 answer
166 views

Unit tests for directory-entry counter

I have a function that simply counts the number of files in a directory. To test this function I am using temporary files which are great in the respect that they are deleted upon creating. However, ...
BigAl1992's user avatar
2 votes
1 answer
84 views

Count features in a file, using parallel code

When processing large files (say for parsing or performing computations based on the contents), we want to be able to use multiple processes to perform the job faster. In my case I wanted to count ...
Bar's user avatar
  • 121
6 votes
1 answer
90 views

Small program to get binary diff offset between two small files

Trivial utility program meant to go through the list of (small) files and report file offset of the first difference between them. The goal of the code is simplicity. Any recommendations are useful. ...
biosckon's user avatar
  • 173
9 votes
4 answers
2k views

Program that finds the longest word not containing one of the disallowed characters

Problem definition Find the longest word that doesn't contain any of the following characters: gkmqvwxz Input comes from a file named ...
Johannes's user avatar
  • 191
4 votes
1 answer
104 views

Making a Zsync file archive with checksums

I'm learning go by doing it. I tried to port the Java's ZsyncMake implementation into Golang. I also employ the Go's concurrency API with goroutine and channel. I have some experience in Java, but ...
imeluntuk's user avatar
  • 223
4 votes
2 answers
680 views

Detect file type using file signatures

My program has to detect the real file type of a given file using signatures. For now I'm just checking JPG, but I want to add more. ...
Milton Cardoso's user avatar
10 votes
4 answers
6k views

Comparing two large binary files in C

I'm trying to read two sufficiently large binary files, comparing them and printing the offset at which they differ. I'm using fread to read the binary files and <...
ampat's user avatar
  • 103
0 votes
1 answer
38 views

Process CSV files that follow the first nonempty one

I have a list of CSV files (all have the same fields), some of which are empty. My goal is to find the first nonempty file and use that as the "base" file for an aggregation. After finding the base ...
kanderson8's user avatar
6 votes
2 answers
2k views

Copy certain lines from one text file to another

I need to open a file, read a line and if that line respect some conditions write it to another file, the line that I'm reading is a normal ASCII string representig HEX values and I need to paste it ...
FabioEnne's user avatar
  • 163
3 votes
1 answer
245 views

Censor the middle of words of length N from a text file

...
Greg M's user avatar
  • 341
7 votes
1 answer
200 views

View, append, write, or delete a file

I am just wondering if I need to refactor this code into smaller functions, or if it is OK as it is. I know that code should be as clean as possible, but I don't see a need to declare a new function ...
Robotica's user avatar

1 2 3
4
5
17