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.
1
vote
0answers
33 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
100 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
53 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
69 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
51 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 ...
4
votes
2answers
62 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
83 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
55 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
101 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
32 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
154 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
130 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
392 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
83 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
60 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
74 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
70 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
72 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
35 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
142 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
177 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
95 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
62 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
149 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 ...
3
votes
2answers
135 views
Analyzer for compression algorithms (or tools)
This file contains the main functions of my tool, rac. In particular, I care a lot about the Shannon function.
Would you please give some hints to make the file cleaner? I have a perversion for ...
3
votes
1answer
80 views
Exporting a table with header and subheader
I have an array matrix, for example A(3,3), I want to make a table with header names like, ['force','mass','acceleration'], the second row contains the units (subheader), ['N','Kg','m/s^2'], and the ...
5
votes
2answers
266 views
Binary file Handling - Add,modify and display records
I have written a basic binary file handling program and have used goto, so I want to know how to improve this program by replacing goto with another function
...
0
votes
1answer
33 views
Split a file into individually allocated lines
This is part of a larger project that is to run on POSIX systems. My concerns with it are the lack of comments, best practices with the filesystem, and naming things. Of course all feedback is great.
...
10
votes
6answers
807 views
Standard way of reading file contents to a buffer
I have been trying to write a sample code block to read file contents into a buffer.
I am assuming that:
Code must be platform independent
Should work in all cases(or report proper error)
It should ...
1
vote
3answers
114 views
Writing numbers into a file [closed]
I'm taking my first ever CS class and I have an assignment due Friday. I just wanted someone to check my code.
Instructions:
Write a program that:
gets the name of a text file of numbers ...
3
votes
2answers
46 views
Small script to re-create a file indefinitely
I created a small ruby script at work to recreate a text file I use for a test in the Java application we are supporting.
I'm still really new to the ruby paradigm and wanted to know if that small ...
2
votes
4answers
52 views
Counting the number of lines in a file
I'm easing back into C after several months of using Python and Matlab. Can anyone give me some pointers on how to improve my code's efficiency and readability?
...
2
votes
3answers
130 views
Wrapping a CSV file for access and testing
I have a simple class that represents and accesses the data from a CSV file (using the CsvHelper library). I've tried restructuring the code to allow for better unit testing, but I'm sure the ...
0
votes
2answers
114 views
Test if file exist
bool isFileExist(const std::string& fileName)
{
return !!std::ifstream(fileName.c_str());
}
This is a function to check if a file exist. Are there non-...
6
votes
2answers
104 views
Counting senders in a mailbox
I'm learning Python from Coursera and am doing a class. One of the assignments is as follows:
Write a program to read through the mbox-short.txt and figure out who has the sent the greatest number ...
1
vote
1answer
60 views
1
vote
2answers
86 views
Python Search file for string and read into list
This function of my program is searching a file that is formatted as first_name last_name rate hours:
John Smith 25 80
Mary Johnson 15.5 60.0
...
With one space ...
6
votes
3answers
68 views
Four versions of a database-creation function with different error handling
I'm starting a new, small C project and would like to have the safest, cleanest and shortest error handling code possible.
Here is a comparison of different ways to handle errors in the same C ...
1
vote
1answer
79 views
Calculate the crc32 of the contents of a file using boost
I'm computing the crc32 of a given file using boost:
...
3
votes
1answer
57 views
Writing a byte array image to disk with an automatically generated filename
I have the following code that that writes large images to disk. My application server is running out of memory and I'm wondering if I could somehow optimize the following:
...
5
votes
2answers
53 views
Search files from large directory and sub-directories
Essentially I have a large directory with many sub-folders and different formats of files. It reads through XML, JAVA, .txt, etc, in search of a selected String inputted by the user. The results ...
4
votes
2answers
47 views
Inserting data into a file
So, given a file with the following format:
[header]
line of data
line of data
line of data
line of data
[header 2]
line of data
line of data
line of data
...
I add a ...
2
votes
1answer
36 views
Updating certain values in text file
So I need to update some certain values within text file based on actual values there. Any advice on making it more effective or just readable is appreciated.
Example text file:
...
3
votes
1answer
66 views
Printing longest lines
Challenge
Write a program which reads a file and outputs a specified number of lines, sorted on length in descending order.
Specifications
The first argument is a path to a file.
The file ...
7
votes
4answers
501 views
Merging two files containing sorted numbers into one
The task is to merge 2 text files containing sorted integers into one file. Each number in both files is stored in new line(there are no empty lines,and only numbers are stored). Requirements are that ...
1
vote
1answer
96 views
3
votes
1answer
201 views
Python program to lock and unlock files
The code takes srcPaths and actionType as parameters. The former is a string with tab-delimited file paths, while the latter is ...
3
votes
2answers
65 views
Check that files don't contain Unicode
I use this code to check that all files in a directory are free from Unicode and non-printable characters.
Can I improve the structure of the code?
...