Skip to content

New style reader #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
With your PR, here is a check list:

- [ ] Has Test cases written
- [ ] Has all code lines tested
- [ ] Has test cases written?
- [ ] Has all code lines tested?
- [ ] Has `make format` been run?
- [ ] Has `moban` been run?
- [ ] Please update CHANGELOG.yml(not CHANGELOG.rst)
- [ ] Passes all Travis CI builds
- [ ] Has fair amount of documentation if your change is complex
- [ ] run 'make format' so as to confirm the pyexcel organisation's coding style
- [ ] Please update CHANGELOG.rst
- [ ] Please add yourself to CONTRIBUTORS.rst
- [ ] Agree on NEW BSD License for your contribution
29 changes: 29 additions & 0 deletions .github/workflows/moban-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on: [push]

jobs:
run_moban:
runs-on: ubuntu-latest
name: synchronize templates via moban
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
- name: check changes
run: |
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 }}
with:
args: >-
This is an auto-commit, updating project meta data,
such as changelog.rst, contributors.rst
26 changes: 26 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- 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 }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,7 @@ cscope.files
cscope.out
cscope.in.out
cscope.po.out


# remove moban hash dictionary
.moban.hashes
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[settings]
line_length=79
known_first_party=pyexcel_io,html5lib
known_third_party=mock,nose,pyexcel
indent=' '
multi_line_output=3
length_sort=1
default_section=FIRSTPARTY
no_lines_before=LOCALFOLDER
sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,LOCALFOLDER
8 changes: 8 additions & 0 deletions .moban.d/custom_travis.yml.jj2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "travis.yml.jj2" %}

{%block custom_python_versions%}
python:
- 3.8
- 3.7
- 3.6
{%endblock%}
3 changes: 1 addition & 2 deletions .moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ overrides: "git://github.com/pyexcel/pyexcel-mobans!/mobanfile.yaml"
configuration:
configuration: pyexcel-htmlr.yml
targets:
- README.rst: custom_README.rst.jj2
- setup.py: custom_setup.py.jj2
- requirements.txt: requirements.txt
- MANIFEST.in: MANIFEST.in.jj2
- "tests/requirements.txt": "tests/custom_requirements.txt.jj2"
- .travis.yml: travis.yml.jj2
- .travis.yml: custom_travis.yml.jj2
- .gitignore: gitignore.jj2
- "docs/source/conf.py": "docs/source/conf.py.jj2"
- "docs/source/index.rst": "index.rst.jj2"
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ language: python
notifications:
email: false
python:
- &pypy2 pypy2.7-6.0
- &pypy3 pypy3.5-6.0
- 3.8
- 3.7
- 3.6
- 3.5
- 2.7

stages:
- lint
Expand All @@ -32,7 +28,7 @@ stages:
env:
- MINREQ=0
stage: moban
install: pip install moban>=0.0.4 gitfs2 pypifs
install: pip install moban gitfs2 pypifs moban-jinja2-github moban-ansible
script:
- moban
- git diff --exit-code
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change log
================================================================================

0.6.0 - tbd
--------------------------------------------------------------------------------

**Updated**

#. New style xlsx plugins, promoted by pyexcel-io v0.6.0.

0.5.2 - 23.10.2017
--------------------------------------------------------------------------------

Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


No contributors yet
=======================

* Your github link will be listed here after your PR is merged
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include README.rst
include LICENSE
include CHANGELOG.rst
include CONTRIBUTORS.rst
recursive-include tests *
recursive-include docs *
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
all: test

test:
test: lint
bash test.sh

document:
bash document.sh
install_test:
pip install -r tests/requirements.txt

spelling:
sphinx-build -b spelling docs/source/ docs/build/spelling
lint:
bash lint.sh

format:
bash format.sh

git-diff-check:
git diff --exit-code
33 changes: 18 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ As a standalone library
... from ordereddict import OrderedDict
... else:
... from collections import OrderedDict
>>> import pyexcel as pe
>>> book_data = {"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [["row 1", "row 2", "row 3"]]}
>>> pe.save_book_as(bookdict=book_data, dest_file_name="your_file.html")


Read from an html file
Expand All @@ -104,7 +107,7 @@ Here's the sample code:
>>> data = get_data("your_file.html")
>>> import json
>>> print(json.dumps(data))
{"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [["row 1", "row 2", "row 3"]]}
{"Table 1": [[1, 2, 3], [4, 5, 6]], "Table 2": [["row 1", "row 2", "row 3"]]}



Expand All @@ -119,10 +122,11 @@ Continue from previous example:
>>> # This is just an illustration
>>> # In reality, you might deal with html file upload
>>> # where you will read from requests.FILES['YOUR_HTML_FILE']
>>> data = get_data(io)
>>> with open('your_file.html', 'r') as html_file:
... io = StringIO(html_file.read().encode())
... data = get_data(io)
>>> print(json.dumps(data))
{"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [[7, 8, 9], [10, 11, 12]]}

{"Table 1": [[1, 2, 3], [4, 5, 6]], "Table 2": [["row 1", "row 2", "row 3"]]}

Pagination feature
********************************************************************************
Expand All @@ -142,25 +146,25 @@ Let's assume the following file is a huge html file:
... [6, 26, 36]
... ]
>>> sheetx = {
... "huge": huge_data
... "Table 1": huge_data
... }
>>> save_data("huge_file.html", sheetx)
>>> pe.save_book_as(dest_file_name="huge_file.html", bookdict=sheetx)

And let's pretend to read partial data:

.. code-block:: python

>>> partial_data = get_data("huge_file.html", start_row=2, row_limit=3)
>>> print(json.dumps(partial_data))
{"huge": [[3, 23, 33], [4, 24, 34], [5, 25, 35]]}
{"Table 1": [[3, 23, 33], [4, 24, 34], [5, 25, 35]]}

And you could as well do the same for columns:

.. code-block:: python

>>> partial_data = get_data("huge_file.html", start_column=1, column_limit=2)
>>> print(json.dumps(partial_data))
{"huge": [[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]]}
{"Table 1": [[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]]}

Obvious, you could do both at the same time:

Expand All @@ -170,7 +174,7 @@ Obvious, you could do both at the same time:
... start_row=2, row_limit=3,
... start_column=1, column_limit=2)
>>> print(json.dumps(partial_data))
{"huge": [[23, 33], [24, 34], [25, 35]]}
{"Table 1": [[23, 33], [24, 34], [25, 35]]}

.. testcode::
:hide:
Expand All @@ -196,13 +200,13 @@ Here is the sample code:
>>> import pyexcel as pe
>>> sheet = pe.get_book(file_name="your_file.html")
>>> sheet
Sheet 1:
Table 1:
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
Sheet 2:
Table 2:
+-------+-------+-------+
| row 1 | row 2 | row 3 |
+-------+-------+-------+
Expand All @@ -220,19 +224,19 @@ You got to wrap the binary content with stream to get html working:
>>> # This is just an illustration
>>> # In reality, you might deal with html file upload
>>> # where you will read from requests.FILES['YOUR_HTML_FILE']
>>> htmlfile = "another_file.html"
>>> htmlfile = "your_file.html"
>>> with open(htmlfile, "rb") as f:
... content = f.read()
... r = pe.get_book(file_type="html", file_content=content)
... print(r)
...
Sheet 1:
Table 1:
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
Sheet 2:
Table 2:
+-------+-------+-------+
| row 1 | row 2 | row 3 |
+-------+-------+-------+
Expand Down Expand Up @@ -320,4 +324,3 @@ What is .moban.d

>>> import os
>>> os.unlink("your_file.html")
>>> os.unlink("another_file.html")
6 changes: 6 additions & 0 deletions changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
releases:
- changes:
- action: Updated
details:
- 'New style xlsx plugins, promoted by pyexcel-io v0.6.0.'
date: tbd
version: 0.6.0
- changes:
- action: updated
details:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

project = 'pyexcel-htmlr'
copyright = '2015-2019 Onni Software Ltd.'
author = 'C.W.'
author = 'chfw'
# The short X.Y version
version = '0.5.2'
version = '0.6.0'
# The full version, including alpha/beta/rc tags
release = '0.5.2'

Expand Down
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
`pyexcel-htmlr` - Let you focus on data, instead of file formats
================================================================================

:Author: C.W.
:Author: chfw
:Source code: http://github.com/pyexcel/pyexcel-htmlr.git
:Issues: http://github.com/pyexcel/pyexcel-htmlr/issues
:License: New BSD License
:Development: |release|
:Released: |version|
:Generated: |today|

Expand Down
2 changes: 1 addition & 1 deletion lint.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip install flake8
flake8 . --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long
flake8 --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long . && python setup.py checkdocs
7 changes: 5 additions & 2 deletions pyexcel-htmlr.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
overrides: "pyexcel.yaml"
name: "pyexcel-htmlr"
nick_name: "htmlr"
version: "0.5.2"
current_version: "0.5.2"
version: "0.6.0"
current_version: "0.6.0"
release: "0.5.2"
file_type: 'html'
dependencies:
- html5lib
- lxml
- pyexcel-io>=0.5.3
test_dependencies:
- pyexcel-text
- pyexcel
description: "read tables in html file as excel data"
Loading