Skip to main content

csv-position-reader

A custom CSV reader implementation with direct file access

The default builtin Python csv lib uses an 8KB read-ahead buffer on the file pointer, making fp.tell() yield inaccurate results. This library addresses that head on, explicitly passing back the file pointer position with each row, as well as allowing for direct seeking.

References:

Usage

>>> import csv_position_reader

>>> with open('tests/data/basic.csv', 'r') as fp:
...     reader = csv_position_reader.DictReader(fp)
...     position, row = reader.next()
...     print "position: %s" % position
...     print "row: %s" % row
...     reader.seek(position)
...     position_new, row_new = reader.next()
...     assert position == position_new
...     assert row == row_new
... 
position: 26
row: {'city': 'Atlanta', 'favorite_color': 'black', 'name': 'Sam'}

Why? / Who Cares?

Because after poring through a CSV one time, you can now build a dictionary/cache of where each row lives for future O(1) access! You're now a stone's throw away from a CSV-driven database!

Metadata

Release files for csv-position-reader 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv-position-reader 0.1.0
File Size Uploaded
csv-position-reader-0.1.0.tar.gz 2.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csv-position-reader 0.1.0
File Interpreter ABI Platform
csv_position_reader-0.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 5.5 kB

Release files / csv-position-reader-0.1.0.tar.gz

Download URL csv-position-reader-0.1.0.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4737871b2b23b3f88b5e3f396d1b41ece7d7477c8aa1f44398cbb660b57ca992
BLAKE2b-256 checksum
How to use checksums
e788895c475df026c17db44fd4b9d5c773123844c58e6395f0e99f713e72d124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

Release files / csv_position_reader-0.1.0-py2.py3-none-any.whl

Download URL csv_position_reader-0.1.0-py2.py3-none-any.whl
Size 3.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2e07e479946b0f9fc7a9ad227653abd12f89f5e2f6973d91624c28b4df542afd
BLAKE2b-256 checksum
How to use checksums
254b2f1a0f5941263573a44ab956358417f54e6c1b3f6dc30f043d3db042470e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page