diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6017f21..8996445 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,6 +4,5 @@ With your PR, here is a check list: - [ ] Has all code lines tested? - [ ] Has `make format` been run? - [ ] Please update CHANGELOG.yml(not CHANGELOG.rst) -- [ ] Passes all Travis CI builds - [ ] Has fair amount of documentation if your change is complex - [ ] Agree on NEW BSD License for your contribution diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3789494 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: lint + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + name: lint code + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: lint + run: | + pip --use-deprecated=legacy-resolver install flake8 + pip --use-deprecated=legacy-resolver install -r tests/requirements.txt + flake8 --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long . + python setup.py checkdocs diff --git a/.github/workflows/moban-update.yml b/.github/workflows/moban-update.yml index 706fd82..4038e3d 100644 --- a/.github/workflows/moban-update.yml +++ b/.github/workflows/moban-update.yml @@ -8,22 +8,22 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} + token: ${{ secrets.PAT }} - name: Set up Python uses: actions/setup-python@v1 with: python-version: '3.7' - name: check changes run: | + pip install markupsafe==2.0.1 pip install moban gitfs2 pypifs moban-jinja2-github moban-ansible moban git status git diff --exit-code - name: Auto-commit if: failure() - uses: docker://cdssnc/auto-commit-github-action - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: stefanzweifel/git-auto-commit-action@v4 with: - args: >- + commit_message: >- This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 9e7ec42..4ccaa8d 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -5,9 +5,16 @@ on: types: [created] jobs: - deploy: + pypi-publish: + name: upload release to PyPI runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: pypi + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write steps: + # retrieve your distributions here - uses: actions/checkout@v1 - name: Set up Python uses: actions/setup-python@v1 @@ -16,11 +23,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + pip install setuptools wheel + - name: Build run: | python setup.py sdist bdist_wheel - twine upload dist/* + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c004ba3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,35 @@ +name: Run unit tests on Windows, Ubuntu and Mac + +on: [push, pull_request] + +jobs: + + test: + name: ${{ matrix.os }} / ${{ matrix.python_version }} + runs-on: ${{ matrix.os }}-latest + strategy: + fail-fast: false + matrix: + os: [Ubuntu] + python_version: ["3.9.16"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + architecture: x64 + + - name: install + run: | + pip --use-deprecated=legacy-resolver install -r requirements.txt + pip --use-deprecated=legacy-resolver install -r tests/requirements.txt + - name: test + run: | + pip freeze + nosetests --verbosity=3 --with-coverage --cover-package pyexcel_xlsxr --cover-package tests tests --with-doctest --doctest-extension=.rst README.rst pyexcel_xlsxr + - name: Upload coverage + uses: codecov/codecov-action@v1 + with: + name: ${{ matrix.os }} Python ${{ matrix.python-version }} \ No newline at end of file diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..9e00174 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,23 @@ +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.12" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/source/conf.py + +# Optionally build your docs in additional formats such as PDF +formats: + - pdf + +python: + install: + - requirements: docs/requirements.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 421fab5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -sudo: false -language: python -notifications: - email: false -python: - - 3.8 - - 3.7 - - 3.6 -before_install: - - if [[ $TRAVIS_PYTHON_VERSION == "2.6" ]]; then pip install flake8==2.6.2; fi - - if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then - mv min_requirements.txt requirements.txt ; - fi - - test ! -f rnd_requirements.txt || pip install --no-deps -r rnd_requirements.txt - - test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ; - - pip install -r tests/requirements.txt -script: - - make test -after_success: - codecov diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 332cd64..885aaf6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Change log ================================================================================ +0.6.1 - 11.11.2024 +-------------------------------------------------------------------------------- + +**Updated** + +#. #9: Potential fix for incorrect reading of data with empty cells when used + with pyexcel + 0.6.0 - 10.10.2020 -------------------------------------------------------------------------------- diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 423f980..16c04e4 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -1,6 +1,8 @@ -No contributors yet -======================= +1 contributors +================================================================================ -* Your github link will be listed here after your PR is merged +In alphabetical order: + +* `Mark Skelton `_ diff --git a/LICENSE b/LICENSE index ba2effe..1720954 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2020 by Onni Software Ltd. and its contributors +Copyright (c) 2015-2024 by Onni Software Ltd. and its contributors All rights reserved. Redistribution and use in source and binary forms of the software as well @@ -13,7 +13,7 @@ that the following conditions are met: and/or other materials provided with the distribution. * Neither the name of 'pyexcel-xlsxr' nor the names of the contributors - may not be used to endorse or promote products derived from this software + may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND diff --git a/README.rst b/README.rst index d55f3d6..1ce7bf7 100644 --- a/README.rst +++ b/README.rst @@ -5,12 +5,9 @@ pyexcel-xlsxr - Let you focus on data, instead of xlsx format .. image:: https://raw.githubusercontent.com/pyexcel/pyexcel.github.io/master/images/patreon.png :target: https://www.patreon.com/chfw -.. image:: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg +.. image:: https://raw.githubusercontent.com/pyexcel/pyexcel-mobans/master/images/awesome-badge.svg :target: https://awesome-python.com/#specific-formats-processing -.. image:: https://travis-ci.org/pyexcel/pyexcel-xlsxr.svg?branch=master - :target: http://travis-ci.org/pyexcel/pyexcel-xlsxr - .. image:: https://codecov.io/gh/pyexcel/pyexcel-xlsxr/branch/master/graph/badge.svg :target: https://codecov.io/gh/pyexcel/pyexcel-xlsxr @@ -18,8 +15,7 @@ pyexcel-xlsxr - Let you focus on data, instead of xlsx format :target: https://pypi.org/project/pyexcel-xlsxr -.. image:: https://pepy.tech/badge/pyexcel-xlsxr/month - :target: https://pepy.tech/project/pyexcel-xlsxr/month + .. image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg @@ -71,6 +67,8 @@ Known constraints Fonts, colors and charts are not supported. +Nor to read password protected xls, xlsx and ods files. + Installation ================================================================================ @@ -314,7 +312,7 @@ Then install relevant development requirements: #. pip install -r tests/requirements.txt Once you have finished your changes, please provide test case(s), relevant documentation -and update CHANGELOG.rst. +and update changelog.yml .. note:: @@ -333,7 +331,7 @@ On Linux/Unix systems, please launch your tests like this:: $ make -On Windows systems, please issue this command:: +On Windows, please issue this command:: > test.bat @@ -345,7 +343,7 @@ Please run:: $ make format -so as to beautify your code otherwise travis-ci may fail your unit test. +so as to beautify your code otherwise your build may fail your unit test. diff --git a/changelog.yml b/changelog.yml index 58c8ddf..37d7ac6 100644 --- a/changelog.yml +++ b/changelog.yml @@ -1,6 +1,12 @@ name: pyexcel-xlsxr organisation: pyexcel releases: +- changes: + - action: Updated + details: + - '#9: Potential fix for incorrect reading of data with empty cells when used with pyexcel ' + date: 11.11.2024 + version: 0.6.1 - changes: - action: Updated details: diff --git a/lint.sh b/lint.sh index 891aa63..d31eeaa 100644 --- a/lint.sh +++ b/lint.sh @@ -1,2 +1,2 @@ pip install flake8 -flake8 --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long . && python setup.py checkdocs +flake8 --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long . && python setup.py checkdocs \ No newline at end of file diff --git a/pyexcel-xlsxr.yml b/pyexcel-xlsxr.yml index 80a9e3e..ced3766 100644 --- a/pyexcel-xlsxr.yml +++ b/pyexcel-xlsxr.yml @@ -1,9 +1,10 @@ overrides: "pyexcel.yaml" name: "pyexcel-xlsxr" nick_name: "xlsxr" -version: "0.6.0" -current_version: "0.6.0" -release: "0.6.0" +version: "0.6.1" +current_version: "0.6.1" +release: "0.6.1" +copyright_year: 2015-2024 file_type: xlsx nodocs: true dependencies: diff --git a/pyexcel_xlsxr/_version.py b/pyexcel_xlsxr/_version.py index 34ce970..91ed185 100644 --- a/pyexcel_xlsxr/_version.py +++ b/pyexcel_xlsxr/_version.py @@ -1,2 +1,2 @@ -__version__ = '0.6.0' -__author__ = 'chfw' +__version__ = '0.6.1' +__author__ = 'C.W.' diff --git a/pyexcel_xlsxr/messy_xlsx.py b/pyexcel_xlsxr/messy_xlsx.py index 22fdba8..22193be 100644 --- a/pyexcel_xlsxr/messy_xlsx.py +++ b/pyexcel_xlsxr/messy_xlsx.py @@ -182,6 +182,14 @@ def __repr__(self): return str(self.value) +def column_to_number(column): + column = re.sub("[^A-Z]", "", column) + cl = len(column) - 1 + return sum( + [(ord(c.upper()) - 64) + (26 * (cl - i)) for i, c in enumerate(column)] + ) + + def parse_row(row_xml_string, book): if b"x14ac" in row_xml_string: row_xml_string = row_xml_string.replace( @@ -191,11 +199,20 @@ def parse_row(row_xml_string, book): cells = [] cell = Cell() + last_column_number = None for action, element in etree.iterparse(partial): - if element.tag in ["v", "t"]: cell.value = element.text elif element.tag in ["c"]: + ref = element.attrib.get("r") + if ref: + column_number = column_to_number(ref) + if last_column_number is not None: + padding = column_number - last_column_number - 1 + if padding > 0: + cells += [Cell() for _ in range(padding)] + last_column_number = column_number + local_type = element.attrib.get("t") cell.column_type = local_type style_int = element.attrib.get("s") diff --git a/setup.py b/setup.py index 6766e86..8073b20 100644 --- a/setup.py +++ b/setup.py @@ -31,15 +31,15 @@ locale.setlocale(locale.LC_ALL, "en_US.UTF-8") NAME = "pyexcel-xlsxr" -AUTHOR = "chfw" -VERSION = "0.6.0" +AUTHOR = "C.W." +VERSION = "0.6.1" EMAIL = "info@pyexcel.org" LICENSE = "New BSD" DESCRIPTION = ( "Read xlsx file using partial xml" ) URL = "https://github.com/pyexcel/pyexcel-xlsxr" -DOWNLOAD_URL = "%s/archive/0.6.0.tar.gz" % URL +DOWNLOAD_URL = "%s/archive/0.6.1.tar.gz" % URL FILES = ["README.rst", "CHANGELOG.rst"] KEYWORDS = [ "python", @@ -73,13 +73,14 @@ } # You do not need to read beyond this line PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable) -GS_COMMAND = ("gs pyexcel-xlsxr v0.6.0 " + - "Find 0.6.0 in changelog for more details") +HERE = os.path.abspath(os.path.dirname(__file__)) + +GS_COMMAND = ("gease pyexcel-xlsxr v0.6.1 " + + "Find 0.6.1 in changelog for more details") NO_GS_MESSAGE = ("Automatic github release is disabled. " + "Please install gease to enable it.") UPLOAD_FAILED_MSG = ( 'Upload failed. please run "%s" yourself.' % PUBLISH_COMMAND) -HERE = os.path.abspath(os.path.dirname(__file__)) class PublishCommand(Command): @@ -125,7 +126,6 @@ def run(self): "publish": PublishCommand }) - def has_gease(): """ test if github release command is installed