Pea Kina aka 'Giant Panda'
Wrapper around pandas library, which detects separator, encoding
and type of the file. It allows to get a group of files with a matching pattern (python or glob regex).
It can read both local and remote files (HTTP/HTTPS, FTP/FTPS/SFTP or S3/S3N/S3A).
The supported file types are csv, excel, json, parquet and xml.
ℹ️ If the desired type is not yet supported, feel free to open an issue or to directly open a PR with the code !
Please, read the documentation for more information
Installation
pip install peakina
Usage
Considering a file file.csv
a;b
0;0
0;1
Just type
>>> import peakina as pk
>>> pk.read_pandas('file.csv')
a b
0 0 0
1 0 1
Or files on a FTPS server:
- my_data_2015.csv
- my_data_2016.csv
- my_data_2017.csv
- my_data_2018.csv
You can just type
>>> pk.read_pandas('ftps://<path>/my_data_\\d{4}\\.csv$', match='regex', dtype={'a': 'str'})
a b __filename__
0 '0' 0 'my_data_2015.csv'
1 '0' 1 'my_data_2015.csv'
2 '1' 0 'my_data_2016.csv'
3 '1' 1 'my_data_2016.csv'
4 '3' 0 'my_data_2017.csv'
5 '3' 1 'my_data_2017.csv'
6 '4' 0 'my_data_2018.csv'
7 '4' 1 'my_data_2018.csv'
Using cache
You may want to keep the last result in cache, to avoid downloading and extracting the file if it didn't change:
>>> from peakina.cache import Cache
>>> cache = Cache.get_cache('memory') # in-memory cache
>>> df = pk.read_pandas('file.csv', expire=3600, cache=cache)
In this example, the resulting dataframe will be fetched from the cache, unless file.csv modification time has changed on disk, or unless the cache is older than 1 hour.
For persistent caching, use: cache = Cache.get_cache('hdf', cache_dir='/tmp')
Use only downloading feature
If you just want to download a file, without converting it to a pandas dataframe:
>>> uri = 'https://i.imgur.com/V9x88.jpg'
>>> f = pk.fetch(uri)
>>> f.get_str_mtime()
'2012-11-04T17:27:14Z'
>>> with f.open() as stream:
... print('Image size:', len(stream.read()), 'bytes')
...
Image size: 60284 bytes
Metadata
Release files for peakina 0.19.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| peakina-0.19.4.tar.gz | 27.9 kB | Without provenance | Details for peakina-0.19.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| peakina-0.19.4-py3-none-any.whl | Python 3 | none | any | Details for peakina-0.19.4-py3-none-any.whl |
Total release size: 54.9 kB
Release files / peakina-0.19.4.tar.gz
| Download URL | peakina-0.19.4.tar.gz |
|---|---|
| Size | 27.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4b6f388499e7035b627b9c42874ad362af0831fa9cd9062864fff864bb53e3d
|
|
BLAKE2b-256 checksum How to use checksums |
e5b70aaf84807cb6e4444510290d0df320a8d1e5bc9959feba605a1c2edb4046
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.12
|
Release files / peakina-0.19.4-py3-none-any.whl
| Download URL | peakina-0.19.4-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7bcfe1acb43a338dbb8996e618d4c27d605c97fd5a33514e7cdf7f644058914
|
|
BLAKE2b-256 checksum How to use checksums |
bb71725482b05b0d6094f6a992a0e4553fff0aa20515d724174ff73d1c0b4916
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.12
|
Security for peakina 0.19.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.