agate-excel 0.2.2

Build status PyPI downloads Version License Support Python versions

agate-excel adds read support for Excel files (xls and xlsx) to agate.

Important links:

Install

To install:

pip install agate-excel

For details on development or supported platforms see the agate documentation.

Usage

agate-excel uses a monkey patching pattern to add read for xls and xlsx files support to all agate.Table instances.

import agate
import agateexcel

Importing agate-excel adds methods to agate.Table. Once you’ve imported it, you can create tables from both XLS and XLSX files.

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 sheet argument to specify which sheet to create the table from.

API

agateexcel.table_xls.from_xls(cls, path, sheet=None, skip_lines=0, encoding_override=None, **kwargs)

Parse an XLS file.

Parameters:
  • path – Path to an XLS file to load or a file-like object for one.
  • sheet – The names or integer indices of the worksheets to load. If not specified then the first sheet will be used.
  • skip_lines – The number of rows to skip from the top of the sheet.
agateexcel.table_xlsx.from_xlsx(cls, path, sheet=None, skip_lines=0, **kwargs)

Parse an XLSX file.

Parameters:
  • path – Path to an XLSX file to load or a file-like object for one.
  • sheet – The names or integer indices of the worksheets to load. If not specified then the “active” sheet will be used.
  • skip_lines – The number of rows to skip from the top of the sheet.

Authors

The following individuals have contributed code to agate-excel:

Changelog

0.2.2

  • Add an encoding_override argument to Table.from_xls() to override the encoding of the input XLS file.

0.2.1 - February 28, 2017

  • Overload Table.from_xls() and Table.from_xlsx() to accept and return multiple sheets.
  • Add a skip_lines argument to Table.from_xls() and 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.

License

The MIT License

Copyright (c) 2017 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.

Indices and tables