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.

learn more… | top users | synonyms

3
votes
3answers
74 views

Counting letters, words, etc. in the input

I'm trying to learn some coding to broaden my scope of knowledge, and I seemed to have run into a bit of a conundrum. I'm trying to create a program to output the number of characters, digits, ...
-3
votes
0answers
19 views

Python writing to file in python does not take place immediately (hangman game) [on hold]

I just started writing a python code for a hangman game and I'm storing the words in a file. I also have given an option to add words based on users will.I have written the code for the same but for ...
1
vote
4answers
70 views

Java class to compute and get a MD5 hash as a string

Here is my class file to compute MD5 hashes on a file. I wanted to be able to easily calculate them without having to create a lot of overhead in the code using the class. Can anyone tell me a list ...
8
votes
3answers
496 views

Read hex from file and convert to decimal

I made a small script to read text file that contain hexadecimal and convert to another file in decimal by using command-line as a filename input. ...
5
votes
1answer
55 views

C program for whitespace normalization

I have made a beginner program using C that uses file handling and formats the given file. Formatting includes removing trailing blank spaces, replacing one or more blanks by a single blank and also ...
4
votes
2answers
72 views

File chunk buffer for Windows programs

The purpose of the ChunkBuffer code below is to designate a "chunk" from a given input file and to loop that chunk (if needed). Its operation is similar to the ...
3
votes
3answers
90 views

C++ - create text file of given size

This code creates a text file and writes a given number of characters to it. Is this a good method, or is there a faster method? ...
-3
votes
0answers
58 views

Logging to rolling log files named with timestamps

I wrote a small app to generate tons of logs. By spec log-files must be re-created every X minutes and named as app_%d-%m-%Y_%H:%i.log. This app is work well, but ...
0
votes
0answers
40 views

Open and read a large number of files from folder [duplicate]

Is this the fastest way to open a large number of files and read their contents? (The folder may contain lakhs of files.) ...
1
vote
1answer
35 views

Class to help dealing with files, with lazy properties

I have the following class to help me deal with files: File class: ...
7
votes
3answers
73 views

Find all needles in the haystack and return their sum

This is based on a programming challenge I recently solved. However, since the writer of the challenge asked me not to disclose the question and/or it's answer, I modified it a little. If it doesn't ...
0
votes
0answers
37 views

Script to run “npm install” for all directories/subdirectories that have a package.json file

So to give some context: I have a relatively large repo with package.json files scattered across it for a bunch of unrelated projects. I just needed a quick script ...
4
votes
1answer
83 views

Determine how many unique numbers there are in a text file

I have a program that has one job: to determine how many unique numbers there are in a text file. The text file contains a string of numbers created by this other program named ...
5
votes
2answers
139 views

Read matrix from file, the C++11/14 way

I am trying to get acquainted with C++11/14, so please tell me if the code below could be written in a more "modern" way. Or, of course, if it could be improved in any way. The function ...
4
votes
1answer
48 views

Thread Safe File Operation

I am trying to make file read and update operations thread safe and prevent race conditions in Python. Am I missing out something, or would this work in production? ...
1
vote
1answer
33 views

Extract a range of rows from one file into another

Wondering if there is anything I can improve upon my code? This method accepts a filename (usually will be the path to the file in txt format), the starting row count of that file and the total ...
2
votes
1answer
58 views

The fastest “find”er of them all?

For part of a project, I was given this directive: The find command will use the directory (dirent) function calls, but will require you to start at a directory and then determine if a file is ...
5
votes
1answer
61 views

Search a file (simple grep clone)

For part of a project, I was given this directive: The grep command will take an exact string and an exact filename as the 2 arguments and you will need to search through the filename for the ...
3
votes
1answer
180 views

Finding line numbers of duplicate lines in a log file

I have a log file with a million lines, and my task is to code something that outputs the lines that have duplicates, and the line numbers. I've thought of two ways to approach this : 1) Use python'...
6
votes
1answer
115 views

List directories (with information)

For part of a project, I was given this directive: The “ls” command will require you to use directory functions to list out what the filenames are in the directory. Functions required to make a ...
3
votes
1answer
27 views

Manipulating /etc/hosts file using Go

This is my first go at a Go program that's not a variation of "Hello {$name}". It's about twice as long as my previous Python implementation, and perhaps an order of magnitude messier. The goal is to ...
1
vote
1answer
52 views

Find all anagrams to a given word from a text file

This program I made takes a word as an input and prints all the anagrams of the word in a given word base from a txt file. I would like advice for code style, Java specific practices etc as I'm new to ...
4
votes
0answers
73 views

Confidential Sign-In Sheet in Java

I was requested to make a Sign-in program for the LGBTA Center at my university. They wanted something where anyone that came by and visited could leave their name and email, but also so that no one ...
4
votes
2answers
126 views

Create Excel file multiple times with different names

I want to create a new Excel files from an Apache POI object. The filename should contain the standard name, the current date and a counter, if necessary, to prevent collisions. I have a working ...
1
vote
0answers
43 views

File manager project (creates and prints file)

I just finished my very simple and beginner-friendly C project and wanted to hear your thoughts and opinions about ways to improve it or something. ...
3
votes
1answer
155 views

C++ Read File line by line

I wanted to have a good review on my code I wrote today to read files in C++ line by line. The file can look something like this: ...
0
votes
1answer
61 views

Line count of each file in a given directory efficiently using akka

This is my first program in akka so I wanted to know if the program is efficient and is using the advantages of actor model. The program's purpose is to scan a given directory for any files and print ...
1
vote
1answer
87 views

Printing a list to a file then reassembling said list

This is a GCSE practice problem, to practice for the actual coursework. Computing's my passion and I'd like to impress the examiners (note: any tips would be appreciated) Essentially, this is simply ...
4
votes
1answer
71 views

Python Hex Viewer

I have created an hex viewer in python, as a timed-challenge by friend. My implementation was in the form of a class, with a separate main file running with argparse...
4
votes
2answers
73 views

Red light, green light… kinda

For an assignment I had to create a client and a server that communicate over a well known FIFO. The server is required to use three threads to serve the client, managed by a semaphore. The code was ...
5
votes
2answers
101 views

Short script to hash files in a directory

What improvements could be made to this script and can you explain why you would make those changes? ...
2
votes
0answers
76 views

Download a PDF and submit it as a print job

I have following Java code, which is to print PDF, but in a busy location this code is taking about 20 to 30 second delay before submitting to the hardware. get the PDF file via the network download ...
3
votes
1answer
109 views

Guessing file type from content

This code is to guess_file type searching its content for known signatures. It is intended to be used both from command line (searching entire media for mismatched extensions) and from code to ...
2
votes
2answers
85 views

Adjusting all depth data in a file by some elevation

The code adds up numbers from two different text files. It opens an input file 'DEPTH.dat' and reads the numbers after some headers as follows: ...
3
votes
0answers
38 views

CLI app to download a .gitignore file

I have written a simple app that adds gitignore files to the current working directory - it does this by reading files hosted on GitHub and then saving them (...
3
votes
2answers
160 views

Print all lines of a text file containing the same duplicated word

I'm implementing my very first Go application and I would like to receive an hint on how to make a certain check faster. I have a huge txt file in which each line ...
3
votes
3answers
267 views

Create and back up files

I have to develop a class that creates new files. If a file with the given name already exists, it should be renamed by addition of the timestamp to the file name. The file name should be human-...
5
votes
3answers
509 views

Open a text file and remove any blank lines

I have the following functions which help me to open a text file and remove any blank (empty) lines: ...
2
votes
2answers
84 views

Minimizing open-close scenario

I have the following code in Python which opens and closes a file in every iteration (using with keyword). In 95 % of iterations ...
4
votes
1answer
63 views

Based on a file containing people's names, output some statistics and generate some modified names

Noobie here. I applied for a job as a Jr. engineer and they gave me this task. After they read through my solution they rejected my application because the code was hard to follow. I'd like to get an ...
3
votes
1answer
14 views

Merging directories and keep files that have more lines

Goal My goal is to merge directories. Whenever a file has the same name in two or more directories, then only the one that has the highest number of lines should be kept. If both files have the same ...
2
votes
2answers
88 views

Printing random lines from a file in Python

Is this the most efficient solution or can the performance be improved? Just opens a file and prints random words (lines with newlines stripped out). ...
2
votes
1answer
79 views

Arduino weather station logger

I made a program that uses the Adafruit pressure sensor, and the DHT22 temperature and humidity sensor to log pressure, temperature and humidity every 30 minutes. I left it outside my house overnight ...
6
votes
2answers
85 views

Parse a file containing key-value pairs followed by coordinates of nodes in a graph

I've a file which is divided into two parts: The header The data part The header has of course a different format than the data part. The header part contains lines that look like this ...
6
votes
1answer
41 views

Library to get entropy of files

This is a simple library I just finished writing. The main function is entropy(), which returns the entropy of a file. I'd really appreciate suggestions to improve ...
4
votes
2answers
165 views

In-place sorting of a binary file using heapsort

I have been working on sorting a file in-place with heapsort. I'm very glad it is working. But the time it takes is just too much. So I was wondering on how I could improve it. Here are my ...
2
votes
1answer
452 views

Compress and decompress a string from a file

This is a task for a computing controlled assessment. I'm wondering if it could be made more efficient. The only things I could think of would be the 'import re' and turning the filename input and ...
4
votes
1answer
101 views

Finding Matches and writing results to file C#

I have a folder that contains around 1000 text files, their sizes varies from few KBs up to 500 MB (Total size is around 60 GB). I have a text file that contains a 166k lines, each line contains a ...
1
vote
1answer
67 views

Given some text and a word list, print the 7 most common correctly spelled words

I've got a basic python function that I've been tasked with finishing in a class. It's already fulfilling all the requirements for an A as it's an introductory course to Python, but I'd like to get ...
4
votes
1answer
213 views

Reading lines of a file into a vector of strings

I have to read from a file and store the data inside an std::vector container. The procedure of opening the file, reading and writing onto the container are enclosed in a routine: readData. Reading ...