A python random access file reader
Project description
This is a small library that allows for reading any given line in a file without having to read all the lines before it
or load the entire file into memory. Only the line indexes and lengths are held in memory, which enables random
access even on very large files at a very minuscule memory cost.
Installation
pip install random-access-file-reader
Usage
Usage is very straightforward, and standard csv line endings (newline character), value delimiter (comma), and
quotation character (double quote) are the defaults. These can be changed in the constructor.
The get_line() and get_line_dicts() methods return a list of rows.
Plain text file example:
from randomAccessReader import RandomAccessReader reader = RandomAccessReader('~/myfile.txt') # single line line = reader.get_lines(2)[0] print line # multiple lines lines = reader.get_lines(3, 3) for l in lines: print l
Csv example:
from randomAccessReader import CsvRandomAccessReader reader = CsvRandomAccessReader('~/myfile.csv') # single line line = reader.get_line_dicts(5)[0] for x in line: print x + " = " line[x] # multiple lines lines = reader.get_line_dicts(6, 6) for l in lines: for x in l: print x + " = " l[x]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for random_access_file_reader-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c8894edcdafa52fc98ee2fbfd2e53a74482c72f1ae138954f1d7938d274bdc9 |
|
MD5 | fc0e6a91c050b1a3e2bb131741fa324d |
|
BLAKE2b-256 | d6946df2369ddedc1c3b373fe1fe68848f9c1be5b7b25296ae9fedb7dfd2cc61 |