About xlref
xlref is an useful library to capture by a simple reference (e.g., A1(RD):..:RD) a table with non-empty cells from Excel-sheets when its exact position is not known beforehand.
This code was inspired by the xleash module of the pandalone library. The reason of developing a similar tool was to have a smaller library to install and improve the performances of reading .xlsx files.
Installation
To install it use (with root privileges):
$ pip install xlref
Or download the last git version and use (with root privileges):
$ python setup.py install
Tutorial
A typical example is capturing a table with a “header” row and convert into a dictionary. The code below shows how to do it:
>>> import xlref as xl
>>> _ref = 'excel.xlsx#ref!A1(RD):RD[%s]'
>>> ref = xl.Ref(_ref % '"dict"')
>>> ref.range # Captured range.
B2:C28
>>> values = ref.values; values # Captured values.
{...}
>>> values['st-cell-move']
'#D5(RU):H1(DL)'
You can notice from the code above that all the values of the dictionary are references. To parse it recursively, there are two options:
add the “recursive” filter before the “dict”:
>>> values = xl.Ref(_ref % '"recursive", "dict"').values >>> values['st-cell-move'].tolist() [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]apply a filter onto dictionary’ values using the extra functionality of the “dict” filter:
>>> values = xl.Ref(_ref % '{"fun": "dict", "value":"ref"}').values >>> values['st-cell-move'].tolist() [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
You have also the possibility to define and use your custom filters as follows:
>>> import numpy as np
>>> xl.FILTERS['my-filter'] = lambda parent, x: np.sum(x)
>>> xl.Ref('#D5(RU):H1(DL)["my-filter"]', ref).values
45.0
An alternative way is to use directly the methods of the filtered results as follows:
>>> xl.Ref('#D5(RU):H1(DL)["sum"]', ref).values
45.0
Metadata
Release files for xlref 1.2.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 |
|---|---|---|---|---|
| xlref-1.2.4.tar.gz | 21.1 kB | Without provenance | Details for xlref-1.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xlref-1.2.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for xlref-1.2.4-py2.py3-none-any.whl |
Total release size: 38.7 kB
Release files / xlref-1.2.4.tar.gz
| Download URL | xlref-1.2.4.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
026db7296d5e85bc0afd6bdf22273db802bab0b70cf51d0582db9ea14103cfb4
|
|
BLAKE2b-256 checksum How to use checksums |
dc8ba50a2d9571940330a28c2d3b072a2d86e322fe76100f320d2acff079096c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / xlref-1.2.4-py2.py3-none-any.whl
| Download URL | xlref-1.2.4-py2.py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3f23f1ce2c4e56ba66f82dd82cc6b1fc66cbb00d9bde66d29b0cd7b30936afcb
|
|
BLAKE2b-256 checksum How to use checksums |
b7efd0dcd59cf38190cbd304d4fde1fa21fffa52d4a6d4946bc705a4bff08e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for xlref 1.2.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.