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
6
votes
2answers
4k views

The most efficient way to merge two lists in Java

I am looking for a way to merge two files with a list of distinct words, one word per line. I have to create a new txt file that would contain all the words of the first list and all the words from ...
6
votes
4answers
4k views

HashMap with MySQL

I have faced a scenario: the task was to read a file which contains 3 Millions IP Address. There is a MySQL table which contains Id,PrimaryIP, ...
6
votes
3answers
115 views

SAT score reader program

This program takes 10 Math SAT scores and 10 Verbal Sat scores from the user, computes the standard deviation and averages, then displays them in a tabular format. After, it displays them to the user ...
6
votes
3answers
217 views

File handling in C

I've created an app to manage students' data which also supports file handling. The Student structure looks like this: ...
6
votes
1answer
408 views

Simple python code takes command line argument for file location and tokenizes text

The usage of this Python program is: python ~/test.py test.txt Here is the source: ...
6
votes
2answers
1k 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
2answers
1k 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 ...
6
votes
3answers
714 views

Loading tab-separated tweet data into an array

I'm working on this school project and was wondering if there was any way of storing this information better, faster, more professionally. I'm also restricted to only using an array; don't ask me we ...
6
votes
3answers
393 views

Generate random 10% of file to be used in testing with Ruby

I'm new to Ruby, but not to programming. I just need a simple script that, given a text file, will pull out around 10% of the lines at random. Below is what I came up with based upon a Python script ...
6
votes
1answer
56 views

Updating generated file

With this algorithm I update an automatically generated verilog-file. The update within this file is done by commenting the assigned wires to specific ports of module instances. Is there a better, ...
6
votes
2answers
185 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-...
6
votes
2answers
3k views

End of line converter

I recently wrote a python script to convert multiple files EOL's from Unix to DOS and vice versa. I am looking for tips to ...
6
votes
1answer
107 views

Merge sort practice

Never written a merge sort for huge files before. So after this mornings question I though I would give it a go. ...
6
votes
1answer
269 views

Speech Recognition Part 2: Classifying Data

Now that I have generated training data, I need to classify each example with a label to train a TensorFlow neural net (first building a suitable dataset). To streamline the process, I wrote this ...
6
votes
1answer
142 views

C program to read a file containing numbers, and then print ones divisible by 3 to another file

The program reads a file containing a list of numbers, and then writes the ones divisible by 3 to another file, and prints the remaining ones (non-divisible) to a third file. Declaring, opening, and ...
6
votes
2answers
408 views

Some sort of console “notepad”

This is notepad that works with list of files (pages w/e) that can be edited (list). You can access each file separately and edit/view it too (rewrite, append, read). Here's my implementation of it. I ...
6
votes
1answer
1k views

Fastest Windows script to move files from one did to a network dir

I wrote a script that moves files older than two days over to a network share (via scheduled task). Windows Task Scheduler doesn't seem to like the script so much, but it works well by itself. Is ...
6
votes
1answer
4k views

Updating a file through C++ streams

The following code is my answer to a Stack Overflow question: ...
6
votes
1answer
161 views

Read a file as 4-line chunks

I want to extract the file content into chunks with perl. I have prepared some code snippets which read a file content into chunks. I want to know what is the best way in Perl? Example-File-Content: ...
6
votes
1answer
706 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 '...
6
votes
1answer
301 views

Dealing with a command line argument (path) with spaces

I created a key in Windows registry to have an option on every folder which allows me to simply right click, choose the right option and have a PDF made, either from JPGS, or PNGs, or TIFs. My ...
6
votes
3answers
3k views

Text file manipulation with Java 8 and Guava

I am trying to do some translation of text files. I have a translation .csv file and a file I need to translate (tab delimited). The translation is creating a file with an extra column of the ...
6
votes
2answers
297 views

Haskell program to rename images based on EXIF data

Moved originally from StackOverflow, not knowing the existence of this sister site ... Must say I find programming in Haskell to require much more cognitive intensity than any other language I've ...
6
votes
1answer
623 views

Python read/write pickled file

Is there a way in Python 2.7 to improve reading/writing speed (or memory consumption of the file) compared to this version? ...
6
votes
1answer
65 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 ...
6
votes
1answer
97 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 ...
6
votes
1answer
3k 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'...
6
votes
1answer
113 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 ...
6
votes
1answer
270 views

Python 3 simple external sort with heapq

I've implemented a minimal external sort of text file using heapq python module. On the few tests I did it seems to works well, but I would like to have some advice to have a cleaner and faster code. ...
6
votes
1answer
49 views

Reformatting Latin vocabulary sets from The Bridge

I am currently studying Latin from Wheelock's Latin. Given that a core component of language learning is memorizing vocabulary I needed somewhere I could memorize vocabulary, online, namely Quizlet (...
6
votes
2answers
157 views

Save a playlist to file in a relatively safe fashion

I am writing a music player in Java / JavaFX. The player allows the user to create playlists (which are a list of songs). These user-created playlists are displayed in the music player's library. ...
5
votes
2answers
198 views

Showing the contents of a file

This program reads a filename from standard input and then prints its content. Please review: ...
5
votes
3answers
2k views

Is this a good way to implement a tile map from a text file?

I'm working on a small final fantasy type game. I have this for a tile map. I was just wondering if this is a good way to do this or if anyone has any suggestions, I would love to read them. ...
5
votes
3answers
276 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? ...
5
votes
4answers
705 views

Arrange lines of a text file

This program orders the lines of a text file alphabetically and prints them out to a new text file. Usage: java Arranger input.txt output.txt Is this the best ...
5
votes
4answers
861 views

change space to underscore in filename using C

I have written my first C program that renames spaces in filenames to underscores. I wonder if there is an easier or more efficient way: ...
5
votes
2answers
148k views

Reading a line from a text file and splitting its contents

I have this kind of file structure MALE:FooBar:32 FEMALE:BarFoo:23 Where I would want to identify the gender and age of person, ...
5
votes
2answers
71k views

Parsing a big text file, extract data & store it in a CSV file

I have a big log file (say 1-3 Gb) which I need to parse, extract data & save it in a CSV file. Text File Data ...
5
votes
4answers
386 views

Putting read data into a combined file based on certain attributes

I have a pretty big method where I read data from files and then put them into a combined file in a specific format based on an ID, first and end timestamp. I already refactored some of my code to ...
5
votes
2answers
73 views

Producing excerpts from a file at specified positions within long lines (>1 M characters)

I'm trying to read a file containing over 10.000 lines and each line contains an ID for an individual and a very long string composed of more than 1 million characters (numbers as example: ...
5
votes
1answer
6k views

Read through a log file to find “Fail” lines

Please bear with me, I'm only about a week into Python. This code is something that I wanted to do once I completed the chapters dealing with opening and reading files, and RegEx. I always feel like ...
5
votes
3answers
790 views

FASTA file processing using Python to invoke external filters

I am very new to programming and this is my first functional code. It works fine but I'm sure that I could use a lot of optimization. If you see any blunders or would be able to help condense the ...
5
votes
2answers
98 views

Read a file with transactions and sum all the revenue for each product ISBN

I am trying to improve the algorithms for the following code! The problem I am trying to solve is that I have nested loops that don't look efficient. This includes the Sales_item.h file from C++ ...
5
votes
5answers
3k views

Remove control and non-ASCII characters from large files

I get huge incoming files (up to 6GB) and they are littered with Control and non-ASCII characters. I need to strip them and I made this routine (below). The problem is that it is insanely slow. I ...
5
votes
3answers
1k views

Correcting duplicate names in array

I have an array of file names. For example: string[] files= { "one.zip", "two.txt", "one.zip", "three.txt", "three.txt", "one.zip" }; And I've developed the ...
5
votes
2answers
22k 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.) ...
5
votes
3answers
127 views

Proper way to find newest file in a directory

I wanted to ask if this is a better way to find a latest file in given directory. This is my current approach: ...
5
votes
2answers
66 views

Python image combiner reading writing

I am writing a simple script that will combine two images at a pixel level, selecting every other pixel from one image, and the other pixels from a second image. ...
5
votes
2answers
358 views

Search string in file, replace it, and write back to file

I have this simple function that just reads a file, replaces all occurances of a string, and write it back to the file: ...
5
votes
1answer
60 views

File editing class

I was making this file editing class (writing to a file, reading a file etc.) in Python and was just looking for any feedback. Note: I've been thinking about removing the ...