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
2
votes
1answer
74 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
7k 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
75 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
6k 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
101 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
743 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
130 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
306 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
419 views

Implementing a temporary data context manager

I implemented a context manager to handle temporary files and directories. ...
1
vote
0answers
383 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
152 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
246 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? ...
0
votes
1answer
13k views

Sort data from a text file in descending order using quick sort

I have a text file containing the following data. ...
4
votes
2answers
168 views

Using a radix tree to find case-insensitive matches in large files

I'm using a radix tree library to find case-insensitive matches from several relatively large files (~24 files each on the order ~150MB). My current algorithm requires me to read the chars of an ...
9
votes
3answers
144 views

Archiving files into directories

This program moves files to a backup directory, archiving them by year of last modification. From a directory like : ...
6
votes
5answers
61 views

Compare files, returning first differing line

Exercise 7-6 from the K&R book. Compares 2 files, printing the line number and content with the first dissimilarity. What am I doing that could be improved? ...
12
votes
2answers
841 views

A minimal CLI password storage and retrieval manager

Its primary function is to retrieve+copy a PW to your clipboard. It'll also add, update, delete key/value(accountName/password) pairs from a JSON formatted dictionary(separate .txt file). It's ...
4
votes
2answers
959 views

Creating multiple files from a list

This piece of code is to get random samples from two String lists, pos and neg. Based on a ...
3
votes
3answers
85 views

Reading and classifying lines from a file

I'm new to C which I'm learning in university now, and I'm not sure if the following is considered in C good practices or not. For an assignment in a simple Classification problem I wrote the ...
3
votes
1answer
206 views

Exporting an object to a ZIP file

I have my own type of object, which implements Serializable. Here I have one called "extendedFormat" (not a terribly helpful name, yes, I know). I'm writing it out ...
3
votes
2answers
221 views

Extract SSID and BSSID from a file

I have file called Network.txt which contains SSID and BSSID as below: ...
8
votes
2answers
5k views

Python code that compares two files byte by byte

I wrote a Python (2.7) script that compares a file byte by byte. filecmp was not suitable for the application because it compares metadata as well. How can I ...
1
vote
1answer
84 views

Overwrite disk space for the purpose of deleting old data

I have written a little program that overwrites memory. It creates useless files in a folder named "folder" (I am so creative). The purpose is to overwrite old data. It's not a very professional ...
4
votes
1answer
136 views

Write a message to a log

I have started to read Robert C. Martin Clean Code book. To learn and gain more expreiences I wrote a single Log class. So I want some suggestions to improve this code.. This is a part of the Log ...
7
votes
2answers
1k views

Find and rename all png files

I have such problem : find all png files to disk and rename them as I did: ...
0
votes
2answers
94 views

Give function get file extension for you

I have written a function that retrieves the extension from a given file name for you. I would like to make this more efficient and increase it's performance. ...
3
votes
1answer
740 views

JSON Cache Program

I have some code that is intended to be a package (so that it can be accessed via import cachejson). Here is the code for the package: The update variable is ...
1
vote
0answers
37 views

Script to append a new method to a XAML code-behind file

My company is converting a VB.NET project to a C# application and I was tasked with writing a script to automate part of the process. In particular, given information about a control name and event in ...
6
votes
1answer
101 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. ...
0
votes
1answer
116 views

PHP Cache weather in a file

I'm using the darksky api to get weather data for a display board website. The free version is limited to 1000 api calls per month. I have a lot of devices (iPads) displaying this information in ...
6
votes
2answers
533 views

Creating index to a file in C

My task was to index a file in C. I'm getting one argument: file name. The index should contain all the words and a line list which appears in. A few notes: Big and small letters are the same. A ...
4
votes
1answer
45 views

Read reference data from external file

This is a function from a program I am working on for my internship, which involves research in computational science. I have some text files with reference data in a directory ...
7
votes
2answers
135 views

Grouping Equivalent Files in Filesystem

The docstring in group_equivalent_files should be self-explanatory for what I'm trying to do. I'm specifically trying to group by equivalent files as opposed to just finding pairs of equivalent files. ...
4
votes
2answers
2k views

generate a file name with format Name(Number).extension

I am writing a program which downloads a file from a URL. Because the name of the downloaded file depends on the url, there is a risk of duplication if the user downloads the same file twice. For ...
2
votes
1answer
45 views

Reading in millions of lines of AOL query logs for query suggestion/expansion

I am working on a query suggestion program, and to faciliate this, I am reading in millions of AOL queries logs. The logs have this format: ...
1
vote
1answer
56 views

Read date from a file and rename two files using the date

Problem I have image files that are RAW data and have the extension .NEF Whatever edits I make to these files are stored in what is called a sidecar file with the ...
-2
votes
1answer
42 views

Finding phrase in specified files v2 c++

Please provide constructive feedback so I can learn from my mistakes. Please tell me what I did right and where I came up with very good solution and where I should improve. Here is the code (Please ...
3
votes
2answers
787 views

C program to handle information of cars and owners

This is a school assignment, it's the longest program I've wrote this far, and I feel it's a bit messy and all over the place. I will try to translate the assignment to the best I can: We have a ...
1
vote
1answer
250 views

C++ Reading Data in a File

I'm not sure if I should ask here. The program worked it's just that I'm not satisfied how I implemented it because I used two while loop to read a specific data and I have no idea what am I doing. ...
4
votes
2answers
1k views

Scanning through logs (tail -f fashion) parsing and sending to a remote server

I have a task at hand to build a utility which Scans through a log file. Rolls over if a log file is reset. Scans through each line of the log file. Each line is sent to an executor service and ...
1
vote
2answers
10k views

AES Encryption/Decryption of Files and Bytes

I have gathered some information about aes256 in c# from the internet and put together this code and I would like to know if this is secure or if its lacking in security. Working encrypt/decrypt ...
3
votes
1answer
91 views

Follow-up 2: Copy File, remove spaces in specific lines

This is an iterative review: The Original Question | Follow up 1 Differences to Follow up 1 This iteration tries to take the previous review to heart and see how it turns out. It sacrifices the ...
3
votes
2answers
148 views

Follow-up 1: Copy File, remove spaces in specific lines

This Question now has a follow-up question After learning a lot about applying OO principles, interfaces and a bit about argument-handling I post a revised version of my previous code. This is still ...
7
votes
2answers
138 views

Finding phrase in specified files

Please provide constructive feedback so I can learn from my mistakes. Please tell me what I did right and where I came up with very good solution and where I should improve. Here is the code (Please ...
4
votes
1answer
435 views

Copy File, remove spaces in specific lines

This question now has a follow-up question 1 and follow-up question 2 As an exercise in writing decent code and because I learn best by example, I wrote this program and would ask for a review so ...
5
votes
4answers
826 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: ...