The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
5
votes
2answers
12k views

Manipulating filenames using Python

I was tasked with creating a script to be able to rename some files and then move them into different folders based on a code in the filename. ...
5
votes
1answer
34k views

Writing/reading data structure to a file using C++

I wrote some piece of code which reads and write multiple data structures on a file using C++. I would be grateful to get your feedback on what you think about the code (it works at least when I ...
5
votes
1answer
6k 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 ...
5
votes
5answers
8k views

Min and max of numbers read from a file

I had to create this program, and I did it fine, all is working and stuff but I was wondering, what is better way of doing such thing? I want more efficient method. Problem assignment: In the file ...
5
votes
2answers
3k views

Fast line-by-line file reader

This is designed for a high performance complex log analyzer. Very simple idea: read a file line-by-line as fast as possible. I would appreciate any hints what should/could be improved in this code. ...
5
votes
3answers
5k views

Reading a file into memory

Can you review below code for performance and stability considerations? It is supposed to take a filename or NULL. If it is a filename, read given file into memory. ...
5
votes
1answer
2k views

Ruby script to load .xlsx files into a MySQL database

I put together this Ruby script (1.9.3) to load data into MySQL from many .xlsx files that contain data entered by people. These files typically have many illegal characters and it has been difficult ...
5
votes
1answer
357 views

Function that converts file eol's

I've been unable to find a PHP function that will convert eol in files. This is what I have so far. It works, no errors. Your educated opinions, thoughts, improvements, potential bugs and ...
5
votes
2answers
761 views

Reading CSV files pertaining to financial recorts

I have a number of text files (they are reports from a financial system) stored in a directory. Each report has a particular piece of text to search for (eg Report Total) and then a range of ...
5
votes
2answers
315 views

Uploading multiple files to server with PHP and JavaScript

I wrote some code to upload multiple files to a server with PHP and JavaScript. I'm happy with the form and JavaScript, below. ...
5
votes
1answer
293 views

Removing duplicates from a file containing IP addresses

I have a big txt file containing some specific IP addresses, and all of them appear more than once (the file has around 13 million lines). The file looks like this (the first octet is set to zero for ...
5
votes
2answers
198 views

Validating a CSV list of contacts and convert it to JSON - Follow Up

This is a follow up to my original post: I've written a class that takes a file, validates the formatting of the lines from an input file and writes the set of valid lines to an output file. Each ...
5
votes
1answer
2k 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...
5
votes
2answers
5k views

Search word in multiple files

I am writing a brute-force method to search for a word. Please review my code and tell me how I can improve it. ...
5
votes
1answer
105 views

Python script to rename images based on descriptions in a text file

I like to collect images for my desktop background, but the problem is sometimes the image names don't represent what the image is. I decided to write a script that reads a text file that contains the ...
5
votes
1answer
52 views

Find big files on the harddrive

For practicing Python I wrote a script which scans the harddrive for large files and lists them in a report. The script takes the root path and then all the subfolders are scanned aswell. Also the ...
5
votes
2answers
66 views

Merging two files' lines of text for output

My program is supposed to merge two text files' lines together. For instance, if I have two files, one.txt: ...
5
votes
2answers
218 views

A python default dictionary which seamlessly saves to disk

I sometimes do experiments at work and separate the computation and the analysis so I can do the computation on a cluster and the analysis locally and sometimes in a Jupyter notebook. I wrote a class ...
5
votes
2answers
4k 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? ...
5
votes
2answers
121 views

Given a path to a directory, print the path to the biggest file in it

Here is my code. I simulated a stack rather than used some regular recursive algorithm because I needed to keep track of two variables: the path to the biggest file and its size. Besides I wrote a few ...
5
votes
2answers
3k views

Read file line-by-line with circular buffer

This isn't too complicated but I usually code in C++ instead of C. Doing memory management and IO in C always makes me feel like I'm doing everything wrong and making a mess. This is a small sample ...
5
votes
1answer
698 views

Edit configuration files script

Script designed to avoid manually edit configuration files by support. Config file example: ...
5
votes
3answers
112 views

Extracting two columns from exported iTunes playlist

My friend wanted me to send her a list of songs from one of my iTunes playlists, so I exported the playlist within the app itself. It comes as a plain text file, where each field is separated a ...
5
votes
1answer
929 views

Improve my copying of a CSV file

I need to merge some large csv files but I feel that the way I am doing it is not optmized. It gets a number of csvfiles and creates one ...
5
votes
1answer
2k views

File reader/writer using XPConnect, ActiveX, LiveConnect, Java, HTML5 file storage, or HTTP

I am writing a file writer/reader in JavaScript; I want it to work on local files. It tries to use Firefox's XpConnect, falls back on IE activeX, falls back on Java LiveConnect, falls back on a Java ...
5
votes
1answer
73 views

Small program to get binary diff offset between two small files

Trivial utility program meant to go through the list of (small) files and report file offset of the first difference between them. The goal of the code is simplicity. Any recommendations are useful. ...
5
votes
2answers
214 views

Implementation of the `tac` command

As a C programming exercise, I implemented a minimal tac program that prints the input line by line starting from the last line. I'm looking for feedback on my ...
5
votes
2answers
909 views

Convert JSON from a webservice to text file

I get list JSON text from a webservice and list_of_columns is predefined, I need the output in that format. I am not sure about few things which are as follows I ...
5
votes
1answer
279 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 ...
5
votes
1answer
394 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 ...
5
votes
2answers
3k 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 ...
5
votes
2answers
817 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 ...
5
votes
1answer
1k views

String parsing and saving ipaddress to file in Java

Following function will parse string resp, which will be like shown in following example. I will get an IP address in the form of a hexadecimal string like "...
5
votes
1answer
7k views

General multithreaded file processing

I'm trying to write a general multithreaded file processing facility. The idea is that some input file consists of a number of discrete records, each record needs to be processed in the same manner, ...
5
votes
1answer
409 views

Reading a list of file paths and adding them to a map

I have many thousands of image files spread around various places and would like to copy them into one directory. However, may of the files are duplicates with the same names (often thumbnails or ...
5
votes
1answer
109 views

Plain-text file encryption and decryption

I have created an Encryption and Decryption Algorithm that encrypts plain text using a given cipher and also decrypts it back to the original notation. It works great. This was my code for a coding ...
5
votes
1answer
69 views

Sorting words by frequency

I'm doing a simple task in Rust after reading the Rust book: read a text file split it at whitespace sanitize words by removing non-letter characters sort the words by their frequency of occurrence ...
5
votes
2answers
171 views

Read lines from a file in chunks

I created a function to read lines from an file into chunks. My hidden agenda in creation this script was in python the yield function in interaction with chunks. The script works fine, but now i ...
5
votes
1answer
3k 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? ...
5
votes
3answers
80 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 ...
5
votes
1answer
788 views

Search file for keyword program

Just looking for some advice and I know using std namespace is bad but I didnt have the time to do all the using stuff. I want help on what here is good and what is bad practice :). ...
5
votes
2answers
4k views

Displaying a new image document in Picturebox

I'm using WinForms and have a picturebox in my form. This program looks in "C:\image\" directory to find a specified image document, in my case a tif file. There is always only one picture in "C:\...
5
votes
1answer
338 views

Cleaning a WPA wordlist

I have a short bash script that processes gigs and gigs of data. I am looking for any improvements to make it faster. This is my very first bash script so please be gentle. I am really only ...
5
votes
1answer
2k views

Checking file size and sending it to the server

I am currently working on a crash log sender. As the application crashes, the FindLogFiles() will search for the different crash logs we are maintaining. It will ...
5
votes
1answer
1k views

Counting words in files

I made a simple program for my study that calculates words in a text files and prints every word and its repeated times in the files. How can I improve this code? ...
5
votes
1answer
1k views

Inspecting properties of files

...
5
votes
1answer
1k views

Reading a binary file containing periodic samples

I have the following code for reading HTK feature files. The code below is working completely correct (verified it with unit tests and the output of the original HTK toolkit). ...
5
votes
1answer
73 views

Two cross-platform implementations of getline in C

I created my cross-platform implementations of getline function in C. It takes different arguments and have different return values than 'original' ...
5
votes
2answers
347 views

Replace the content of a file by zero-bytes and keep the same filesize

Here is a little tool for Windows that replaces the content of a file with zero-bytes, keeping the same filesize. It works. The goal is to be sure that the old bytes-content of the file is no more ...
5
votes
1answer
106 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 ...