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
Hashes for fast_csv_loader-1.0.0.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5858cdca58b764a854dc1176d9e4e285f420c8e685051c5e3a71ac7ddcdb6996 |
|
MD5 | fcf0831daf4a51d8e7be2b6812073a25 |
|
BLAKE2b-256 | 727833725f2a8d8702a9207974360269461e8e22bbd509c834dd724cc542df95 |
Hashes for fast_csv_loader-1.0.0.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c6fe00e79bdece4fb9ea192385cd8aef52eff9601b458d4d89a913735f0bb83 |
|
MD5 | 3835f7553fc2be76e514b1af6e795ad0 |
|
BLAKE2b-256 | b737e7c56a6fb275aaf001a85bbd16b681282b00a57a7d00233c864867301540 |