xlref


Namexlref JSON
Version 1.2.4 PyPI version JSON
download
home_pagehttps://github.com/vinci1it2000/xlref
SummaryExcel table reader library.
upload_time2024-02-27 14:28:13
maintainer
docs_urlNone
authorVincenzo Arcidiacono
requires_python
licenseEUPL 1.1+
keywords python utility library data scientific range engineering data excel tables reader reference
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
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
<https://github.com/pandalone/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):

.. code:: console

   $ pip install xlref

Or download the last git version and use (with root privileges):

.. code:: console

   $ 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:

   1. 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]]

   2. 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vinci1it2000/xlref",
    "name": "xlref",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,utility,library,data,scientific,range,engineering,data,excel,tables,reader,reference",
    "author": "Vincenzo Arcidiacono",
    "author_email": "vinci1it2000@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dc/8b/a50a2d9571940330a28c2d3b072a2d86e322fe76100f320d2acff079096c/xlref-1.2.4.tar.gz",
    "platform": null,
    "description": "\nAbout xlref\n***********\n\n**xlref** is an useful library to capture by a simple reference (e.g.,\n*A1(RD):..:RD*) a table with non-empty cells from Excel-sheets when\nits exact position is not known beforehand.\n\nThis code was inspired by the *xleash* module of the `pandalone\n<https://github.com/pandalone/pandalone>`_ library. The reason of\ndeveloping a similar tool was to have a smaller library to install and\nimprove the performances of reading *.xlsx* files.\n\n\nInstallation\n************\n\nTo install it use (with root privileges):\n\n.. code:: console\n\n   $ pip install xlref\n\nOr download the last git version and use (with root privileges):\n\n.. code:: console\n\n   $ python setup.py install\n\n\nTutorial\n********\n\nA typical example is *capturing* a table with a \u201cheader\u201d row and\nconvert into a dictionary. The code below shows how to do it:\n\n>>> import xlref as xl\n>>> _ref = 'excel.xlsx#ref!A1(RD):RD[%s]'  \n>>> ref = xl.Ref(_ref % '\"dict\"')\n>>> ref.range  # Captured range.\nB2:C28\n>>> values = ref.values; values  # Captured values.\n{...}\n>>> values['st-cell-move']\n'#D5(RU):H1(DL)'\n\nYou can notice from the code above that all the values of the\ndictionary are references. To parse it recursively, there are two\noptions:\n\n   1. add the \u201crecursive\u201d filter before the \u201cdict\u201d:\n\n      >>> values = xl.Ref(_ref % '\"recursive\", \"dict\"').values\n      >>> values['st-cell-move'].tolist()\n      [[1.0, 2.0, 3.0],\n       [4.0, 5.0, 6.0],\n       [7.0, 8.0, 9.0]]\n\n   2. apply a filter onto dictionary\u2019 values using the extra\n      functionality of the \u201cdict\u201d filter:\n\n      >>> values = xl.Ref(_ref % '{\"fun\": \"dict\", \"value\":\"ref\"}').values\n      >>> values['st-cell-move'].tolist()\n      [[1.0, 2.0, 3.0],\n       [4.0, 5.0, 6.0],\n       [7.0, 8.0, 9.0]]\n\nYou have also the possibility to define and use your custom filters as\nfollows:\n\n>>> import numpy as np\n>>> xl.FILTERS['my-filter'] = lambda parent, x: np.sum(x)\n>>> xl.Ref('#D5(RU):H1(DL)[\"my-filter\"]', ref).values\n45.0\n\nAn alternative way is to use directly the methods of the filtered\nresults as follows:\n\n>>> xl.Ref('#D5(RU):H1(DL)[\"sum\"]', ref).values\n45.0\n",
    "bugtrack_url": null,
    "license": "EUPL 1.1+",
    "summary": "Excel table reader library.",
    "version": "1.2.4",
    "project_urls": {
        "Documentation": "http://xlref.readthedocs.io",
        "Donate": "https://donorbox.org/xlref",
        "Download": "https://github.com/vinci1it2000/xlref/tarball/v1.2.4",
        "Homepage": "https://github.com/vinci1it2000/xlref",
        "Issue tracker": "https://github.com/vinci1it2000/xlref/issues"
    },
    "split_keywords": [
        "python",
        "utility",
        "library",
        "data",
        "scientific",
        "range",
        "engineering",
        "data",
        "excel",
        "tables",
        "reader",
        "reference"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7efd0dcd59cf38190cbd304d4fde1fa21fffa52d4a6d4946bc705a4bff08e11",
                "md5": "bf8194bea7d17ca8bfc5957289011b65",
                "sha256": "3f23f1ce2c4e56ba66f82dd82cc6b1fc66cbb00d9bde66d29b0cd7b30936afcb"
            },
            "downloads": -1,
            "filename": "xlref-1.2.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf8194bea7d17ca8bfc5957289011b65",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 17612,
            "upload_time": "2024-02-27T14:28:09",
            "upload_time_iso_8601": "2024-02-27T14:28:09.098608Z",
            "url": "https://files.pythonhosted.org/packages/b7/ef/d0dcd59cf38190cbd304d4fde1fa21fffa52d4a6d4946bc705a4bff08e11/xlref-1.2.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc8ba50a2d9571940330a28c2d3b072a2d86e322fe76100f320d2acff079096c",
                "md5": "e6eecfe8cc523adde3c0dee0b95c2457",
                "sha256": "026db7296d5e85bc0afd6bdf22273db802bab0b70cf51d0582db9ea14103cfb4"
            },
            "downloads": -1,
            "filename": "xlref-1.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e6eecfe8cc523adde3c0dee0b95c2457",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21093,
            "upload_time": "2024-02-27T14:28:13",
            "upload_time_iso_8601": "2024-02-27T14:28:13.399459Z",
            "url": "https://files.pythonhosted.org/packages/dc/8b/a50a2d9571940330a28c2d3b072a2d86e322fe76100f320d2acff079096c/xlref-1.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-27 14:28:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vinci1it2000",
    "github_project": "xlref",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "xlref"
}
        
Elapsed time: 0.19569s