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.
0
votes
1answer
29 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.
...
8
votes
6answers
691 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
73 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
1answer
31 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
47 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
92 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
66 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
55 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
51 views
1
vote
2answers
58 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
42 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
50 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
42 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
45 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
61 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
472 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 ...
0
votes
1answer
58 views
3
votes
1answer
106 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
82 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
62 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
43 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
169 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
144 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
30 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
47 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
61 views
2
votes
1answer
113 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
111 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
186 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
89 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
85 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 ...
1
vote
1answer
144 views
Multiple emails and attachments, reusing memory stream
I am generating a pdf form based on user input from an MVC website form. The pdf is genrated using the Foxit .NET SDK, then attached to three separate emails, generated using Postal. It has been ...
3
votes
1answer
40 views
Putting a matrix from a text file into a list
I'm trying to read a text file with matrix and put it in a list, but I am using two loops here and I want my function to be faster.
...
5
votes
2answers
143 views
Counting occurrences of a word in a file
This gives me the output of how many times the word is in the file. (I will eventually want to enhance the program to output on what line of the file the word is.)
...
4
votes
1answer
37 views
Using arrays to read in file, append it with parsed program output and overwrite original
Yesterday a friend of mine asked on U&L: How to optimize 'grep'-and-save?
I will summarise shortly. The output of the torque pbs queueing system tool qstat ...
10
votes
1answer
147 views
Fuzzy grep for fuzzy bears in pure Python
I am aware of the Python modules galore to do this, but this was partially a learning experience and partially all the functionality I need and no more.
I'm writing a simple interpreter for a Forth-...
-3
votes
1answer
56 views
Reading a file byte by byte in Java [closed]
I am currently using this:
Path path = Paths.get("c:\test\test.txt");
byte[] all= Files.readAllBytes(path);
The problem with this is that I have to load the ...
4
votes
1answer
63 views
Watch log dir for new file, automatically tail to slack
We have a process that outputs to log files in the format /var/log/xxx/YYYY_MM_DD.log - the file name is chosen programmatically and is not rotated using logrotate ...
4
votes
1answer
91 views
Application for encrypting and decrypting files in Java - follow-up
(Everything needed for running the app is here.)
I have refactored my previous version a bit.
App.java:
...
3
votes
1answer
210 views
Application for encrypting and decrypting files in Java
(See the next iteration.)
I have that application for en-/decrypting files. Here, I will post the actual GUI and command line code. In order to run the program refer to this GitHub repository.
Some ...
2
votes
1answer
89 views
Two Java methods for easy writing and reading bytes in files
I have these easy-to-use methods for reading and writing binary data in files.
FileTools.java:
...
2
votes
3answers
84 views
Duplicate Line Finder
I recently wrote a program that reads a plain text file, and compares every line and alerts you if any are similar, based on a float value that you pass in to a function.
...
4
votes
3answers
105 views
Counts the number of times a particular character, such as e, appears in a file
This question came from a Java tutorial online:
Write an example that counts the number of times a particular character, such as e, appears in a file.
I was just wondering if there is any way to ...
8
votes
4answers
159 views
Python Implementation - Conway's Game of Life
This is my implementation of Conway's Game of Life in Python. Now since I am a novice coder, naturally I have some key doubts:
The usage of idioms and code redundancies - Are there any small ...
3
votes
2answers
69 views
BMP file writer
In my current project I'm writing a C function to write a BMP-File. Internally, the function is split up into three parts: write header, write info header, write data.
In some of these functions I do ...
3
votes
3answers
89 views
Creating and manipulating FITS files
I wrote a program that manipulated data from VLA observations and created FITS files to be used in creating spectral energy distributions of high redshift radio galaxies. I really tried to be as ...