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.
2
votes
1answer
13 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
0answers
33 views
Authenticate a user, and password, display coresponding file, login fail 3 times exit, convert password to md5 hash [on hold]
I have to ask for a username and password, then convert the password to a MD5 hash,
and compare the username password and hash to a file of credentials that has username, hash, password, and access ...
2
votes
2answers
60 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
59 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 ...
-1
votes
0answers
29 views
Reading from a file and then stdin [closed]
I have to read <cmd> <str> from the file first until first meets exit. If there is no ...
-1
votes
0answers
20 views
Assigning a value with file read [closed]
I have a .txt file with a number in each line. I want to assign each number to diferent int variables. Each variable have nothing to do with each other, and that's ...
6
votes
2answers
62 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 ...
5
votes
1answer
32 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
128 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
77 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 ...
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
129 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
133 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
74 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
166 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
32 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
746 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
88 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
51 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
111 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
86 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
78 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
59 views
1
vote
2answers
68 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
61 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
54 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
48 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
46 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
64 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
489 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
81 views
3
votes
1answer
140 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
64 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?
...
2
votes
1answer
124 views
Creating archive from over 3GB of files in less than 1 minute
This is a follow up to this question. I got some very good answers for my process speed, and wanted to go ahead and share what I've done with the program. The new updates of the program consist of the ...
6
votes
1answer
86 views
Speeding up process time while archiving files
I asked this question on Stackoverflow, and was told I might have better luck here.
I'm new to c# and have created a basic file archiver. It works, and it does what it's suppose to do, but I think it'...
1
vote
1answer
67 views
File archiver, archive files into a zip file
I've created a simple little file archiver that will run through a given directory and extract your files into an archive folder. It's pretty cool if I do so say myself, I would like some critique on ...
4
votes
1answer
46 views
Secure file system utility functions
For Khronos, I've had to develop these utility functions to help me deal with storing the .wav files. However, they could also be used in a variety of applications....
2
votes
2answers
193 views
Idiomatic word counting in Rust
My goal is to read from standard input, break up the input into words, case-insensitively, and produce a report to standard output, where each line is a word followed by a space followed by its count. ...
2
votes
1answer
148 views
Delimited file parser
This is some code I've cobbled together that reads a delimited file. If the user is able to tell us some stuff about the file, it uses the supplied information. Otherwise, it tries to work stuff out ...
4
votes
1answer
32 views
Prompt system from reading a text file
I worked starting from basic example code from an exercise in chapter 10 of Java: A Beginner's Guide, Sixth Edition, the code in the exercise was not very good and I wanted to improve upon it and make ...
6
votes
1answer
49 views
Randomly selecting an adjective and noun, combining them into a message
This is my first Rust program. I have previously written a lot of Python, and some C. I would like some advice on whether I am doing things idiomatically, and any improvements I could make! I also ...
3
votes
1answer
84 views
2
votes
1answer
119 views
Loading data from a text file into the database as fast as possible
I'm building a Django (1.8.12) application that parses a .bc3 file (Standard Interchange Format for Databases of Construction and Real State) and loads all the data into the database (PostgreSQL 9.3.9)...
10
votes
2answers
124 views
Java hex dumper
Can somebody please try and help me speed up my code? The file is ~12MB (you can download it here). It takes around 500-600 milliseconds to run on my i7 4790k.
...
6
votes
1answer
205 views
Quote of the day program
Create a class diagram and Java code for the following system and
scenario, taking into account the possibility of future extensions.
The system is a command line utility that prints a short '...
3
votes
3answers
92 views
Scrape HTML into separate files for each chapter
I have written a program to read HTML file, find particular text, write text from that particular text to next particular text in a newly opened file. I am interested in code review. I am very new PHP....
1
vote
2answers
102 views
Find a specific file, or find all executable files within the system path
I wrote a function to find a specific file, or all the executable files with a given name and accessing flag, and I want to make ...