Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
1answer
32 views

Python code to get all lines between two keyword lines in a file (with exceptions)

I have coded multiple variations on this and would like to make it generic, to avoid coding any more variations. Comments and suggested improvements, please, (typos also), and what about that ToDo ? ...
2
votes
1answer
41 views

Concatenating an already existing filename to create a new file

I had answered this question from stackoverlow and the code below is code that I wrote to explain to the OP a possible way to achieve what I believe they were looking for. The general idea that I ...
9
votes
5answers
2k views

Basic C copy file implementation

I'm a java programmer by trade and starting to learn C/C++. I'd appreciate any pointers on glaring issues with my code style which is acceptable in java but not in C. I feel like open_files is ...
2
votes
1answer
49 views

Locate substrings within a file

Here, I am reading in a newline delimited file that can be millions of repeating lines that looks like this: ...
3
votes
2answers
169 views

Write output file, collating groups of up to 7 input lines

I have this code that reads a file and after processing a few lines writes the output to a second file: ...
3
votes
2answers
36 views

Implementation of getdelim

Note: I wasn't trying to follow the POSIX getdelim signature exactly. I needed to add the consume argument for a project I'm ...
2
votes
1answer
65 views

Finding the longest word without these characters follow-up

Here I asked this question: My goal is to go through the list of all English words (separated by '\n' characters) and find the longest word which doesn't have ...
2
votes
1answer
56 views

Looping through file finding sequences

For an assignment, I had to loop through a text file, and report any positions that a user entered sequence was found. Is there any way I can make this code more efficient, because it seems like I'm ...
3
votes
3answers
152 views

Count characters of a text file

This program counts the number of the occurence of each character that is used in a file. I tried to use everything that Java offers to me properly. If you have tips which library functions would ...
1
vote
2answers
56 views

Reading new data from a constantly updating file in Java

I have a log file which is constantly updated with new lines of data. I need to get new added data in java as soon as it's written. For now my solution is: ...
1
vote
2answers
80 views

Write byte array to end of file

I'm writing a byte array at the end of file. The code works fine, but can you please suggest performance improvements? ...
5
votes
2answers
70 views

Invert rows and columns in an Excel file

Annother little excercise with openpyxl: Say you have a Excel file like this: The Goal is to make make it look like this: My code to acomplish this: inversion.py ...
2
votes
1answer
29 views

Excel blank row inserter

I wrote a program as an excercise, to check the openpyxl module, which inserts blank rows into an excel file. See the docstring in the code for more description. I ...
0
votes
1answer
53 views

Java splitting too large text file enhance performance

I have a too large data.txt file containing data as follows: ...
2
votes
0answers
30 views

vb.net Create textfile from template

What is the best approach for creating textfiles from/with a template ? Currently I just read the template from a textfile and Replace all values needed, but I don't think that this is the most solid ...
5
votes
1answer
44 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 ...
1
vote
0answers
23 views

“Function” to extract a file in Batch

Recently, I've been doing more and more Batch "programming". I always find myself in the need to extract a file and do something with the files. This is not my first version, and a few non-general-...
2
votes
1answer
106 views

Mad Libs excercise

I did the following Excercise from Automate the boring stuff with Python Chapter 8: Create a Mad Libs program that reads in text files and lets the user add their own text anywhere the word ...
6
votes
2answers
312 views

Text Duplicate filter in Python 3.7

I wrote this program just to remove duplicates from wordlist used for brute-force, but it can be used for every txt file i guess. It is a pretty long program for what it does, and I'm sure there is a ...
1
vote
0answers
19 views

Encapsulating simple license backup to a disk

I am enapsulating my license backup to disk, using an interface ILicenseProvider and the implementation is DiskLicenseProvider. Also i am throwing an unchecked exception LicenseProviderException which ...
6
votes
2answers
116 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-...
2
votes
1answer
50 views

Unit tests for directory-entry counter

I have a function that simply counts the number of files in a directory. To test this function I am using temporary files which are great in the respect that they are deleted upon creating. However, ...
2
votes
1answer
41 views

Count features in a file, using parallel code

When processing large files (say for parsing or performing computations based on the contents), we want to be able to use multiple processes to perform the job faster. In my case I wanted to count ...
5
votes
1answer
69 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. ...
9
votes
4answers
1k views

Program that finds the longest word not containing one of the disallowed characters

Problem definition Find the longest word that doesn't contain any of the following characters: gkmqvwxz Input comes from a file named ...
4
votes
1answer
42 views

Making a Zsync file archive with checksums

I'm learning go by doing it. I tried to port the Java's ZsyncMake implementation into Golang. I also employ the Go's concurrency API with goroutine and channel. I have some experience in Java, but ...
4
votes
2answers
138 views

Detect file type using file signatures

My program has to detect the real file type of a given file using signatures. For now I'm just checking JPG, but I want to add more. ...
9
votes
4answers
2k views

Comparing two large binary files in C

I'm trying to read two sufficiently large binary files, comparing them and printing the offset at which they differ. I'm using fread to read the binary files and <...
0
votes
1answer
32 views

Process CSV files that follow the first nonempty one

I have a list of CSV files (all have the same fields), some of which are empty. My goal is to find the first nonempty file and use that as the "base" file for an aggregation. After finding the base ...
6
votes
2answers
510 views

Copy certain lines from one text file to another

I need to open a file, read a line and if that line respect some conditions write it to another file, the line that I'm reading is a normal ASCII string representig HEX values and I need to paste it ...
3
votes
1answer
70 views
7
votes
1answer
167 views

View, append, write, or delete a file

I am just wondering if I need to refactor this code into smaller functions, or if it is OK as it is. I know that code should be as clean as possible, but I don't see a need to declare a new function ...
2
votes
1answer
36 views

ProcessPoolExecutor KMZ file search

I've written a script to look for coordinates in KMZ files. I've tried to speed execution up using the ProcessPoolExecutor. I'm quite new to Python, so any recommendations are more than welcome. <...
2
votes
1answer
59 views

Read a directory of CSV files in R

I'm writing a lot of R in my spare time and am trying to get into good habits by using TidyVerse as much as possible. A large part of this has required reading entire directories of dated log files ...
4
votes
3answers
204 views

Library Management using File Handling

I have never written program in file handling. Help me improve this program. book.h ...
2
votes
1answer
102 views

Deadbeef : finding all words made of hexadecimal digits

Hexadecimal 0xdead, 0xbeef are the magic numbers because they're also English words. I decided to find such words as many as possible. How to do it? We need large ...
3
votes
1answer
120 views

Get the common values between two text files

I'm just trying to get the common values from two distinct files called file1.txt and file2.txt where I'm using Python's ...
7
votes
1answer
352 views

A little Python hex editor

First off I'm quite new to Python, there will be a lot of messy/overcomplicated code, that's why I'm posting on this site. This code is written in Python (2.7) using the Tkinter library. Questions ...
7
votes
1answer
154 views

Python tool to assemble CodeReview posts from source files

I hate having to format questions around here. Adding four spaces to each source file and the correct name at the top of each source file becomes a headache when I have to post longer questions. This ...
10
votes
3answers
412 views

Implementation of Linux cp in modern C++

This is my simple implementation of the Unix cp command. It is a C++ program but makes use of some of the lower level C library I/O functions. Any suggestions for ...
0
votes
1answer
64 views

Reading lines from a file and processing them concurrently

I'd like to read lines from a file and process them concurrently. I came up with the following code to do this: ...
7
votes
2answers
145 views

Cleaning a file / Word Query

In a followup this application was turned into a GUI using FLTK: Cleaning a file / Word Query GUI (FLTK) I did the following two exercises in Programming: Principles and Practice Using C++ (2nd ...
1
vote
2answers
121 views

VBA - faster way to list out files in a folder & subfolders

I have written a VBA code in excel (basically through combining various codes from others -_-") to list out the path, file name, file size & extension of all files under a folder and the sub-...
1
vote
0answers
41 views

Excercise from PPP Order class

I did the following two excercise from PPP by Stroustrup: Define an Order class with (customer) name, address, data, and ...
5
votes
0answers
42 views

Comparing same-size files and reporting on the differences byte-by-byte

I created a small Python utility to analyze multiple same-size files and report on the difference byte-by-byte (i.e. Hamming distance, not Levenshtein distance.) I am planning to extend the ...
4
votes
2answers
59 views

Escaped line reader

The idiomatic way of reading lines from a file doesn't work for my purposes because the files I'm dealing with might have lines that are escaped. I came up with the below (which seems to meet my needs)...
4
votes
1answer
54 views

Minimalist config file reader/writer

I have written a simple configuration file reader and writer in D that is intended to parse string[string] associative arrays (the whole file is one array) and ...
4
votes
2answers
73 views

Importing files into Excel

Any tips to reduce lines, improve speed, or any cool thing, are welcome. I have been using this for years and I just realized, why not improve ...? ...
2
votes
2answers
75 views

Random binary digit generation and file I/O

I've recently made a program which generates a (pseudo) random binary digit (1,0) which is tied to a specific subject to learn for every day of the week. The program generates the digits the first ...
7
votes
3answers
131 views

Convert binary raster file to text CSV

I have a binary file input.hgt from the Shuttle Radar Topography Mission. It contains a 3601✕3601 matrix, stored as 2-Byte big-endian integer numbers. My code ...