A fast and memory efficient way to load large CSV files (Timeseries data) into Pandas
Project description
fast_csv_loader.py
The csv_loader
function efficiently loads a partial portion of a large CSV file containing time-series data into a pandas DataFrame.
The function allows:
- Loading the last N lines from the end of the file.
- Loading the last N lines from a specific date.
It can load any type of time-series (both timezone aware and Naive) and daily or intraday data.
It is useful for loading large datasets that may not fit entirely into memory. It also improves program execution time, when iterating or loading a large number of CSV files.
Supports Python >= 3.8
Install
pip install fast-csv-loader
Documentation
https://bennythadikaran.github.io/fast_csv_loader/
Performance
Loading a portion of a large file is significantly faster than loading the entire file in memory. Files used in the test were not particularly large. You may need to tweak the chunk_size parameter for your use case.
It is slower for smaller files or if you're loading nearly the entire portion of the file.
I chose a 6Kb chunk size based on testing with my specific requirements. Your requirements may differ.
csv_loader vs pandas.read_csv
To run this performance test.
py tests/run.py
At the minimum, the CSV file must contain a Date and another column with newline chars at the end to correctly parse and load.
Date,Price\n
2023-12-01,200\n
Unit Test
To run the test:
py tests/test_csv_loader.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fast_csv_loader-1.0.1.tar.gz
.
File metadata
- Download URL: fast_csv_loader-1.0.1.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c35473284a2f7cec65987ac3cd6dc0ebeddccafd56fe2542869f835e855e9544 |
|
MD5 | d92187a414f13ee9fa386ef92f0e00ae |
|
BLAKE2b-256 | a6a4fcc30670f110db96a9f08cff704fc92aa81ac1bb732a382b113746a50910 |
Provenance
The following attestation bundles were made for fast_csv_loader-1.0.1.tar.gz
:
Publisher:
publish-to-pypi.yml
on BennyThadikaran/fast_csv_loader
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
fast_csv_loader-1.0.1.tar.gz
- Subject digest:
c35473284a2f7cec65987ac3cd6dc0ebeddccafd56fe2542869f835e855e9544
- Sigstore transparency entry: 146358961
- Sigstore integration time:
- Predicate type:
File details
Details for the file fast_csv_loader-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: fast_csv_loader-1.0.1-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f7937319bc4d6b5c8e910f4fa48b78ea1dba4e0c71b929f5fcc7f4ca02f54b |
|
MD5 | b275ead97b7d2b7618da23ad617a0709 |
|
BLAKE2b-256 | 17faa842996e8fd633d710ca33673985216c1d345c2af1cf5a719fae258cb8ee |
Provenance
The following attestation bundles were made for fast_csv_loader-1.0.1-py3-none-any.whl
:
Publisher:
publish-to-pypi.yml
on BennyThadikaran/fast_csv_loader
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
fast_csv_loader-1.0.1-py3-none-any.whl
- Subject digest:
63f7937319bc4d6b5c8e910f4fa48b78ea1dba4e0c71b929f5fcc7f4ca02f54b
- Sigstore transparency entry: 146358962
- Sigstore integration time:
- Predicate type: