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
3
votes
1answer
86 views

Scraping metrics from log files

https://github.com/bodgix/log2metric/pull/1 This is my very first Go program so please forgive any beginner errors. This is a rewrite of a monitoring script I had written in Ruby. Coming from Ruby, ...
5
votes
1answer
59 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 ...
3
votes
2answers
240 views

Reading lines of integers into a list of lists

I have a text file containing integers in different lines which I want to read into a list of lists. So 01 11 14 45 50 09 should become ...
7
votes
1answer
442 views

Computing a hash value of a file

I am trying to see if there is a more efficient way of creating a hash of a file of unknown size (could be gb). My code below works fine but I am sure there is a more efficient way of achieving this. ...
4
votes
0answers
107 views

File operations using Groovy

The idea is to read a file - "data" - and write the information to a new file - "output" - only if it meets the criteria (if the resource usage is more than a configured threshold). Content of the ...
16
votes
3answers
2k views

92 Spoons AI, sort of an AI in C++

I have made an AI that takes a user input and returns a predefined value. It that stores its info in a file (with the name of the file "default.92ai"). I thought ...
6
votes
1answer
339 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: ...
1
vote
0answers
37 views

Speed up generate excel file

I have little knowledge about java (I'm just starting). I have issues in my generate excel file code. It takes some time to generate the file. Could you please take a look at it? ...
3
votes
1answer
160 views

Retrieve TOC from PDF

I am reading 'Python Trick' in PDF type. To have a big picture of the book, I aim to get a structure dict of TOC from the book. So I copied its TOC from PDF to typora(a markdown editor) and solve the ...
2
votes
1answer
34 views

Retrieve Data from TOC

I aim to convert the TOC of The Python Language Reference — Python 3.6.3 documentation to a structured data with the following steps: Copy contents to a plr.md ...
2
votes
1answer
43 views

Retrieve the shared words from files

I have two files of dip.md and tp.md, which copied respectively from Think Python and Dive Into Python 3 By comparing them, I ...
4
votes
1answer
1k views

Binary data utility class

I have recently been trying to get a solid grasp of how to work with binary data, both for networking and file storage, in C++. In java, there are many utility classes that made this easy. Since these ...
0
votes
2answers
143 views

Reading numbers from three text files in C++

This code is supposed to read some text files. What should I do in order to optimize my code. I was confused about writing a user defined function so that I can pass any text to it and it stores it in ...
23
votes
4answers
2k views

Perl CGI script to serve a PDF file

In a different post I showed the following Perl CGI script. Someone in the comments said that "You're using a lot of very unperlish syntax, and I'd like to give you some feedback". So, here it ...
8
votes
3answers
745 views

XOR cipher C program

I was learning about getopt to parse command line options and I decided to write this small XOR cipher program for files. It acts as a "UNIX filter" (I guess) ...
2
votes
1answer
360 views

Split a data file into files for each time step

I have written a simple code to extract different time steps from a big text file. It works for small text files, but not for bigger text files as input. ...
1
vote
1answer
238 views

Backup of directory

I'm a student that have been learning java for the last year. I have recently created a little program that creates a backup of a directory (it creates a directory named backup0 and copies all files ...
2
votes
1answer
124 views

Extracting file names from text file

I need to extract file names with their extension from an input text file to a string vector. The input text file is quite messy and serves as configuration file for some application. What I know ...
4
votes
1answer
192 views

Reading records from a FoxBASE database file

I'm working on implementing a library that can read/write from FoxBASE files in C#. I can't use ODBC for this, because it's not supported in .NET core. I've got the reading working, but it's ...
6
votes
3answers
1k views

Removing empty lines from a file

The below code removes empty line from test.txt. I posted this answer on StackOverflow but someone commented that this code needs review and suggested me to post ...
9
votes
1answer
579 views

Reading a file without blocking the main thread

Background Info: Running Python 3.6 on Windows 10 I have a text file parsed like this: Ann Marie,Smith,ams@cia.com There can over 100+ names in the text file. ...
1
vote
1answer
678 views

Java method to load random paragraph from text file

Looking for some critique for this code. but ultimately I would like to be directed to resources/books that address my code writing weaknesses, in terms of style structure an convention : The task is ...
5
votes
1answer
559 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? ...
2
votes
2answers
436 views

Simple yet threadsafe file cache in java

I'm attempting to cache contents of a file to avoid frequent reads, using a very simple implementation in a single class. The file contains a list of emailids, one per line. The file changes rarely, ...
0
votes
1answer
155 views

Powershell GetKeystate with outfile

I got a keylogger Powershell script to protocol my input, since I'm quite paranoid if someone uses my PC. However, some letters (I have an anti-ghosting keyboard) are swallowed if I type them in fast....
7
votes
1answer
2k views

Tokenizing a file with a generator

I'm parsing (specifically tokenizing) a file, line-by-line. I've a method tokenize, that takes a string (one line of code, it can't take the whole file at once), breaks it into parts, and returns a ...
0
votes
2answers
224 views

Print every line of file, last to first, with recursion

Had a discussion with a friend to solve this extra credit problem, and we came up with two separate solutions. What are the differences between these two? Is one better than the other? How can I make ...
2
votes
1answer
63 views

Small database with a user defined size

This is a program that accepts user input for a database size - number of rows and data size. After creating the database the user should be able to read, add, remove and list entries and the file ...
1
vote
1answer
4k views

Get file absolute path from file URL in PHP

Reading several questions regarding the topic, I made my function to return file's absolute path from the file URL. As I'm using this in an WordPress environment, hence I availed ...
1
vote
1answer
66 views

Function for store data - C++ [closed]

Given the following definition for a NODE in a linked list: struct NODE { int data; NODE* next; }; I want a function to store the nodes with odd data to a given ...
5
votes
2answers
303 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 ...
4
votes
1answer
2k views

Python CSV file slicer

I have made CSV file slicer. This is my first and biggest piece of code on Python. It takes one .csv file from current folder and then slices it to n parts and adds ...
2
votes
2answers
132 views

For names sake - Project Euler 22

Project Euler - 22 Names scores Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin ...
-3
votes
2answers
3k views

Working around a Segmentation Fault for reading Files in C [closed]

I am getting a segmentation fault on the below snippet, only when I go above a text file in the range of 80-100kb. It will read smaller files of text but otherwise ...
2
votes
1answer
73 views

Reading numbers from a file using map

I want to read a list of IDs (as integers) from a file in Python3. The file has a single ID per line and no blank lines. ...
7
votes
1answer
6k views

CSV file reader in PHP that supports large files (>15k lines)

I have written the following function in PHP to read a CSV file. It works correctly for small files. However, if I try to read in files that are bigger than 15k lines, it takes between 1–2 ...
3
votes
2answers
74 views

Sort a file on the first two columns, with optional filtering

I am a newbie to Rust and low-level coding. I come from data science and I have always used scripting languages so I may have done weird or useless things (with lifetimes and references). This is ...
11
votes
5answers
5k views

Most common words in a text file of about 1.1 million words

I'm learning programming with Python. I’ve written the code below for finding the most common words in a text file that has about 1.1 million words. It is working fine, but I believe there is always ...
3
votes
2answers
98 views

Python file overwriting script

I am fairly new to Python and I'm trying to make a script that does three basic things: prints the contents of a file, overwrites it with your new lines, and prints the new file. I rewrote the script ...
4
votes
2answers
64 views

Translating status codes to messages in log files

I'm not overly efficient when it comes to coding, and I am looking for ways to improve the speed of a log translator I built. Several files are uploaded to a folder on a server and log files are ...
-1
votes
1answer
686 views

Reading bytes from file to compute its SHA256 hash

I need to get text hash (sha 256), so I need to convert file to its type representation. Is this a fast way to get a byte representation of a file? ...
2
votes
2answers
126 views

Simple authentication and registration of users

I have created a simple authentication script in python that can add users and provides a login function. I've tried to thow as much security into this as possible, which probably wasn't the best ...
1
vote
0answers
34 views

Check whether or not write permission is enabled in a remote server

I have written C++ code which will say whether write permission is enable on the server or not using the smbclient command. Since the smbclient command is not returning a proper error code if the ...
1
vote
1answer
100 views

Read in a file, check that it meets certain criteria

This was my original posting: Check that a data file contains the expected number of rows and columns of integers I updated the code. Still what could I improve on? Another question I have is how ...
1
vote
1answer
2k views

Check that a data file contains the expected number of rows and columns of integers

This is a class I wrote check to check the format of .dat files. My code makes sure that the content of the files satisfies the conditions. A file can be deemed invalid if: The file can't be found. ...
2
votes
1answer
275 views

Parallelly resizing mutiple photos

This code snippet is supposed to utilize async await to resize a photo file into multiple sizes in parallel. I just want to know if I am doing it in the right way. I would love to hear some ideas on ...
7
votes
1answer
361 views

Implementing a temporary data context manager

I implemented a context manager to handle temporary files and directories. ...
1
vote
0answers
353 views

Save protobuf-net serialized data with variable length to a file

My program gets continuously raw input from a stream (TCP), then process the data and output the data to a graph. It should also save the data to a file so it can be read afterwards. To archive this I ...
6
votes
2answers
143 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. ...
0
votes
2answers
195 views

Function to test whether file is in use

I needed a method to test whether a given file is in use. Is the code below up to the task? ...