[Python-modules-commits] [python-agate-excel] 01/03: New upstream version 0.2.1
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Mar 22 11:18:02 UTC 2017
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository python-agate-excel.
commit b401e6e9ab7d26bf0940189e9461c64d19d5c60f
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date: Wed Mar 15 06:48:42 2017 +0000
New upstream version 0.2.1
---
.gitignore | 12 ++
.travis.yml | 12 ++
AUTHORS.rst | 6 +
CHANGELOG.rst | 22 ++++
COPYING | 21 +++
MANIFEST.in | 3 +
README.rst | 28 ++++
agateexcel/__init__.py | 4 +
agateexcel/table_xls.py | 134 ++++++++++++++++++++
agateexcel/table_xlsx.py | 117 +++++++++++++++++
docs/Makefile | 130 +++++++++++++++++++
docs/conf.py | 225 +++++++++++++++++++++++++++++++++
docs/index.rst | 77 +++++++++++
example.py | 13 ++
examples/test.xls | Bin 0 -> 31744 bytes
examples/test.xlsx | Bin 0 -> 32092 bytes
examples/test_ambiguous_date.xls | Bin 0 -> 23040 bytes
examples/test_ambiguous_date.xlsx | Bin 0 -> 9304 bytes
examples/test_empty.xls | Bin 0 -> 59904 bytes
examples/test_empty.xlsx | Bin 0 -> 21594 bytes
examples/test_numeric_column_name.xls | Bin 0 -> 59904 bytes
examples/test_numeric_column_name.xlsx | Bin 0 -> 23121 bytes
examples/test_sheets.xls | Bin 0 -> 32256 bytes
examples/test_sheets.xlsx | Bin 0 -> 28086 bytes
examples/test_skip_lines.xls | Bin 0 -> 59904 bytes
examples/test_skip_lines.xlsx | Bin 0 -> 27335 bytes
examples/test_zeros.xls | Bin 0 -> 30720 bytes
requirements-py2.txt | 10 ++
requirements-py3.txt | 8 ++
setup.cfg | 2 +
setup.py | 43 +++++++
tests/__init__.py | 0
tests/test_table_xls.py | 118 +++++++++++++++++
tests/test_table_xlsx.py | 107 ++++++++++++++++
tox.ini | 28 ++++
35 files changed, 1120 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..62c9247
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+.DS_Store
+*.pyc
+*.swp
+*.swo
+.tox
+*.egg-info
+docs/_build
+dist
+.coverage
+build
+.proof
+.test.png
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b8823ad
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+language: python
+python:
+ - "2.7"
+ - "3.3"
+ - "3.4"
+ - "3.5"
+# command to install dependencies
+install:
+ - if [[ $TRAVIS_PYTHON_VERSION == 3* ]]; then pip install -r requirements-py3.txt; else pip install -r requirements-py2.txt; fi
+# command to run tests
+script: nosetests tests
+sudo: false
diff --git a/AUTHORS.rst b/AUTHORS.rst
new file mode 100644
index 0000000..058c201
--- /dev/null
+++ b/AUTHORS.rst
@@ -0,0 +1,6 @@
+The following individuals have contributed code to agate-excel:
+
+* `Christopher Groskopf <https://github.com/onyxfish>`_
+* `James McKinney <https://github.com/jpmckinney>`_
+* `Ben Welsh <https://github.com/palewire>`_
+* `Peter M. Landwehr <https://github.com/pmlandwehr>`_
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..424ae10
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,22 @@
+0.2.1 - February 28, 2017
+-------------------------
+
+* Overload :meth:`.Table.from_xls` and :meth:`.Table.from_xlsx` to accept and return multiple sheets.
+* Add a ``skip_lines`` argument to :meth:`.Table.from_xls` and :meth:`.Table.from_xlsx` to skip rows from the top of the sheet.
+* Fix bug in handling ambiguous dates in XLS. (#9)
+* Fix bug in handling an empty XLS.
+* Fix bug in handling non-string column names in XLSX.
+
+0.2.0
+-----
+
+* Fix bug in handling of ``None`` in boolean columns for XLS. (#11)
+* Removed usage of deprecated openpyxl method ``get_sheet_by_name``.
+* Remove monkeypatching.
+* Upgrade required agate version to ``1.5.0``.
+* Ensure columns with numbers for names (e.g. years) are parsed as strings.
+
+0.1.0
+-----
+
+* Initial version.
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..15aa61e
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2015 Christopher Groskopf and contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..45eee36
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include COPYING
+include AUTHORS.rst
+include README.rst
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..91b0427
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,28 @@
+.. image:: https://travis-ci.org/wireservice/agate-excel.png
+ :target: https://travis-ci.org/wireservice/agate-excel
+ :alt: Build status
+
+.. image:: https://img.shields.io/pypi/dw/agate-excel.svg
+ :target: https://pypi.python.org/pypi/agate-excel
+ :alt: PyPI downloads
+
+.. image:: https://img.shields.io/pypi/v/agate-excel.svg
+ :target: https://pypi.python.org/pypi/agate-excel
+ :alt: Version
+
+.. image:: https://img.shields.io/pypi/l/agate-excel.svg
+ :target: https://pypi.python.org/pypi/agate-excel
+ :alt: License
+
+.. image:: https://img.shields.io/pypi/pyversions/agate-excel.svg
+ :target: https://pypi.python.org/pypi/agate-excel
+ :alt: Support Python versions
+
+agate-excel adds read support for Excel files (xls and xlsx) to `agate <https://github.com/wireservice/agate>`_.
+
+Important links:
+
+* agate http://agate.rtfd.org
+* Documentation: http://agate-excel.rtfd.org
+* Repository: https://github.com/wireservice/agate-excel
+* Issues: https://github.com/wireservice/agate-excel/issues
diff --git a/agateexcel/__init__.py b/agateexcel/__init__.py
new file mode 100644
index 0000000..336c50b
--- /dev/null
+++ b/agateexcel/__init__.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+import agateexcel.table_xls
+import agateexcel.table_xlsx
diff --git a/agateexcel/table_xls.py b/agateexcel/table_xls.py
new file mode 100644
index 0000000..15a0d49
--- /dev/null
+++ b/agateexcel/table_xls.py
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+
+"""
+This module contains the XLS extension to :class:`Table <agate.table.Table>`.
+"""
+
+import datetime
+from collections import OrderedDict
+
+import agate
+import six
+import xlrd
+
+def from_xls(cls, path, sheet=None, skip_lines=0, **kwargs):
+ """
+ Parse an XLS file.
+
+ :param path:
+ Path to an XLS file to load or a file-like object for one.
+ :param sheet:
+ The names or integer indices of the worksheets to load. If not specified
+ then the first sheet will be used.
+ :param skip_lines:
+ The number of rows to skip from the top of the sheet.
+ """
+ if not isinstance(skip_lines, int):
+ raise ValueError('skip_lines argument must be an int')
+
+ if hasattr(path, 'read'):
+ book = xlrd.open_workbook(file_contents=path.read())
+ else:
+ with open(path, 'rb') as f:
+ book = xlrd.open_workbook(file_contents=f.read())
+
+ multiple = agate.utils.issequence(sheet)
+ if multiple:
+ sheets = sheet
+ else:
+ sheets = [sheet]
+
+ tables = OrderedDict()
+
+ for i, sheet in enumerate(sheets):
+ if isinstance(sheet, six.string_types):
+ sheet = book.sheet_by_name(sheet)
+ elif isinstance(sheet, int):
+ sheet = book.sheet_by_index(sheet)
+ else:
+ sheet = book.sheet_by_index(0)
+
+ column_names = []
+ columns = []
+
+ for i in range(sheet.ncols):
+ data = sheet.col_values(i)
+ name = six.text_type(data[skip_lines]) or None
+ values = data[skip_lines + 1:]
+ types = sheet.col_types(i)[skip_lines + 1:]
+
+ excel_type = determine_excel_type(types)
+
+ if excel_type == xlrd.biffh.XL_CELL_BOOLEAN:
+ values = normalize_booleans(values)
+ elif excel_type == xlrd.biffh.XL_CELL_DATE:
+ values = normalize_dates(values, book.datemode)
+
+ column_names.append(name)
+ columns.append(values)
+
+ rows = []
+
+ if columns:
+ for i in range(len(columns[0])):
+ rows.append([c[i] for c in columns])
+
+ tables[sheet.name] = agate.Table(rows, column_names, **kwargs)
+
+ if multiple:
+ return agate.MappedSequence(tables.values(), tables.keys())
+ else:
+ return tables.popitem()[1]
+
+def determine_excel_type(types):
+ """
+ Determine the correct type for a column from a list of cell types.
+ """
+ types_set = set(types)
+ types_set.discard(xlrd.biffh.XL_CELL_EMPTY)
+
+ # Normalize mixed types to text
+ if len(types_set) > 1:
+ return xlrd.biffh.XL_CELL_TEXT
+
+ try:
+ return types_set.pop()
+ except KeyError:
+ return xlrd.biffh.XL_CELL_EMPTY
+
+def normalize_booleans(values):
+ normalized = []
+
+ for value in values:
+ if value is None or value == '':
+ normalized.append(None)
+ else:
+ normalized.append(bool(value))
+
+ return normalized
+
+def normalize_dates(values, datemode=0):
+ """
+ Normalize a column of date cells.
+ """
+ normalized = []
+
+ for v in values:
+ if not v:
+ normalized.append(None)
+ continue
+
+ v_tuple = xlrd.xldate.xldate_as_datetime(v, datemode).timetuple()
+
+ if v_tuple[3:6] == (0, 0, 0):
+ # Date only
+ normalized.append(datetime.date(*v_tuple[:3]))
+ elif v_tuple[:3] == (0, 0, 0):
+ normalized.append(datetime.time(*v_tuple[3:6]))
+ else:
+ # Date and time
+ normalized.append(datetime.datetime(*v_tuple[:6]))
+
+ return normalized
+
+agate.Table.from_xls = classmethod(from_xls)
diff --git a/agateexcel/table_xlsx.py b/agateexcel/table_xlsx.py
new file mode 100644
index 0000000..f027d32
--- /dev/null
+++ b/agateexcel/table_xlsx.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+
+"""
+This module contains the XLSX extension to :class:`Table <agate.table.Table>`.
+"""
+
+import datetime
+from collections import OrderedDict
+
+import agate
+import openpyxl
+import six
+
+NULL_TIME = datetime.time(0, 0, 0)
+
+def from_xlsx(cls, path, sheet=None, skip_lines=0, **kwargs):
+ """
+ Parse an XLSX file.
+
+ :param path:
+ Path to an XLSX file to load or a file-like object for one.
+ :param sheet:
+ The names or integer indices of the worksheets to load. If not specified
+ then the "active" sheet will be used.
+ :param skip_lines:
+ The number of rows to skip from the top of the sheet.
+ """
+ if not isinstance(skip_lines, int):
+ raise ValueError('skip_lines argument must be an int')
+
+ if hasattr(path, 'read'):
+ f = path
+ else:
+ f = open(path, 'rb')
+
+ book = openpyxl.load_workbook(f, read_only=True, data_only=True)
+
+ multiple = agate.utils.issequence(sheet)
+ if multiple:
+ sheets = sheet
+ else:
+ sheets = [sheet]
+
+ tables = OrderedDict()
+
+ for i, sheet in enumerate(sheets):
+ if isinstance(sheet, six.string_types):
+ sheet = book[sheet]
+ elif isinstance(sheet, int):
+ sheet = book.worksheets[sheet]
+ else:
+ sheet = book.active
+
+ column_names = []
+ rows = []
+
+ for i, row in enumerate(sheet.iter_rows(row_offset=skip_lines)):
+ if i == 0:
+ column_names = [None if c.value is None else six.text_type(c.value) for c in row]
+ continue
+
+ values = []
+
+ for c in row:
+ value = c.value
+
+ if value.__class__ is datetime.datetime:
+ # Handle default XLSX date as 00:00 time
+ if value.date() == datetime.date(1904, 1, 1) and not has_date_elements(c):
+ value = value.time()
+
+ value = normalize_datetime(value)
+ elif value.time() == NULL_TIME:
+ value = value.date()
+ else:
+ value = normalize_datetime(value)
+
+ values.append(value)
+
+ rows.append(values)
+
+ tables[sheet.title] = agate.Table(rows, column_names, **kwargs)
+
+ f.close()
+
+ if multiple:
+ return agate.MappedSequence(tables.values(), tables.keys())
+ else:
+ return tables.popitem()[1]
+
+def normalize_datetime(dt):
+ if dt.microsecond == 0:
+ return dt
+
+ ms = dt.microsecond
+
+ if ms < 1000:
+ return dt.replace(microsecond=0)
+ elif ms > 999000:
+ return dt.replace(microsecond=0) + datetime.timedelta(seconds=1)
+
+ return dt
+
+def has_date_elements(cell):
+ """
+ Try to use formatting to determine if a cell contains only time info.
+
+ See: http://office.microsoft.com/en-us/excel-help/number-format-codes-HP005198679.aspx
+ """
+ if 'd' in cell.number_format or \
+ 'y' in cell.number_format:
+
+ return True
+
+ return False
+
+agate.Table.from_xlsx = classmethod(from_xlsx)
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..4c0acf6
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,130 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/agateexcel.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/agateexcel.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/agateexcel"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/agateexcel"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ make -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..255f713
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,225 @@
+# -*- coding: utf-8 -*-
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import os
+import sys
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('..'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
+autodoc_member_order = 'bysource'
+
+intersphinx_mapping = {
+ 'python': ('http://docs.python.org/3.5/', None),
+ 'agate': ('http://agate.readthedocs.org/en/latest/', None)
+}
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'agate-excel'
+copyright = u'2015, Christopher Groskopf'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.2.1'
+# The full version, including alpha/beta/rc tags.
+release = '0.2.1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd: # only import and set the theme if we're building docs locally
+ import sphinx_rtd_theme
+ html_theme = 'sphinx_rtd_theme'
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'agateexceldoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'agate-excel.tex', u'agate-excel Documentation',
+ u'Christopher Groskopf', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+]
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..8c562ed
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,77 @@
+=====================
+agate-excel |release|
+=====================
+
+.. include:: ../README.rst
+
+Install
+=======
+
+To install:
+
+.. code-block:: bash
+
+ pip install agate-excel
+
+For details on development or supported platforms see the `agate documentation <http://agate.readthedocs.org>`_.
+
+Usage
+=====
+
+agate-excel uses a monkey patching pattern to add read for xls and xlsx files support to all :class:`agate.Table <agate.table.Table>` instances.
+
+.. code-block:: python
+
+ import agate
+ import agateexcel
+
+Importing agate-excel adds methods to :class:`agate.Table <agate.table.Table>`. Once you've imported it, you can create tables from both XLS and XLSX files.
+
+.. code-block:: python
+
+ table = agate.Table.from_xls('examples/test.xls')
+ print(table)
+
+ table = agate.Table.from_xlsx('examples/test.xlsx')
+ print(table)
+
+ table = agate.Table.from_xlsx('examples/test.xlsx', sheet=1)
+ print(table)
+
+ table = agate.Table.from_xlsx('examples/test.xlsx', sheet='dummy')
+ print(table)
+
+ table = agate.Table.from_xlsx('examples/test.xlsx', sheet=[1, 'dummy'])
+ print(table)
+
+Both ``Table`` methods accept a :code:`sheet` argument to specify which sheet to create the table from.
+
+===
+API
+===
+
+.. autofunction:: agateexcel.table_xls.from_xls
+
+.. autofunction:: agateexcel.table_xlsx.from_xlsx
+
+Authors
+=======
+
+.. include:: ../AUTHORS.rst
+
+Changelog
+=========
+
+.. include:: ../CHANGELOG.rst
+
+License
+=======
+
+.. include:: ../COPYING
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/example.py b/example.py
new file mode 100755
index 0000000..8b41846
--- /dev/null
+++ b/example.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+import agate
+import agateexcel
+
+table = agate.Table.from_xls('examples/test.xls')
+
+print(table)
+
+table = agate.Table.from_xlsx('examples/test.xlsx')
+
+print(table)
+table.print_table()
diff --git a/examples/test.xls b/examples/test.xls
new file mode 100644
index 0000000..d8b41db
Binary files /dev/null and b/examples/test.xls differ
diff --git a/examples/test.xlsx b/examples/test.xlsx
new file mode 100644
index 0000000..5fe87e5
Binary files /dev/null and b/examples/test.xlsx differ
diff --git a/examples/test_ambiguous_date.xls b/examples/test_ambiguous_date.xls
new file mode 100644
index 0000000..86d4928
Binary files /dev/null and b/examples/test_ambiguous_date.xls differ
diff --git a/examples/test_ambiguous_date.xlsx b/examples/test_ambiguous_date.xlsx
new file mode 100644
index 0000000..b3ecd33
Binary files /dev/null and b/examples/test_ambiguous_date.xlsx differ
diff --git a/examples/test_empty.xls b/examples/test_empty.xls
new file mode 100644
index 0000000..e0feb12
Binary files /dev/null and b/examples/test_empty.xls differ
diff --git a/examples/test_empty.xlsx b/examples/test_empty.xlsx
new file mode 100644
index 0000000..426bb8a
Binary files /dev/null and b/examples/test_empty.xlsx differ
diff --git a/examples/test_numeric_column_name.xls b/examples/test_numeric_column_name.xls
new file mode 100644
index 0000000..ceeccfb
Binary files /dev/null and b/examples/test_numeric_column_name.xls differ
diff --git a/examples/test_numeric_column_name.xlsx b/examples/test_numeric_column_name.xlsx
new file mode 100644
index 0000000..85a5c7e
Binary files /dev/null and b/examples/test_numeric_column_name.xlsx differ
diff --git a/examples/test_sheets.xls b/examples/test_sheets.xls
new file mode 100644
index 0000000..79ea49c
Binary files /dev/null and b/examples/test_sheets.xls differ
diff --git a/examples/test_sheets.xlsx b/examples/test_sheets.xlsx
new file mode 100644
index 0000000..9deaf2b
Binary files /dev/null and b/examples/test_sheets.xlsx differ
diff --git a/examples/test_skip_lines.xls b/examples/test_skip_lines.xls
new file mode 100644
index 0000000..76883ac
Binary files /dev/null and b/examples/test_skip_lines.xls differ
diff --git a/examples/test_skip_lines.xlsx b/examples/test_skip_lines.xlsx
new file mode 100644
index 0000000..e910dd4
Binary files /dev/null and b/examples/test_skip_lines.xlsx differ
diff --git a/examples/test_zeros.xls b/examples/test_zeros.xls
new file mode 100644
index 0000000..56c5049
Binary files /dev/null and b/examples/test_zeros.xls differ
diff --git a/requirements-py2.txt b/requirements-py2.txt
new file mode 100644
index 0000000..b465395
--- /dev/null
+++ b/requirements-py2.txt
@@ -0,0 +1,10 @@
+unittest2==0.5.1
+nose>=1.1.2
+tox>=1.3
+Sphinx>=1.2.2
+sphinx_rtd_theme>=0.1.6
+wheel>=0.24.0
+ordereddict>=1.1
+xlrd>=0.9.4
+openpyxl>=2.3.0
+agate>=1.2.2
diff --git a/requirements-py3.txt b/requirements-py3.txt
... 344 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-agate-excel.git
More information about the Python-modules-commits
mailing list