pyexcel - Let you focus on data, instead of file formats¶
Author: | C.W. |
---|---|
Source code: | http://github.com/chfw/pyexcel |
Issues: | http://github.com/chfw/pyexcel/issues |
License: | New BSD License |
Version: | 0.1.7 |
Generated: | July 03, 2015 |
Introduction¶
pyexcel provides one application programming interface to read, manipulate and write data in different excel formats. This library makes information processing involving excel files an enjoyable task. The data in excel files can be turned into array or dict with least code, vice versa. And ready-made custom filters and formatters can be applied. This library focuses on data processing using excel files as storage media hence fonts, colors and charts were not and will not be considered.
Excel files are de-facto file format for information sharing in non-software centric organisations. Excel files are not only used for mathematical computation in financial institutions but also used for many other purposes in an office work environment. This is largely casued by wide adoption of Microsoft Office. Comparing the existing, mathematics savvy Pandas library, this library intends to help data processing job where data extraction is more important than data analysis. In such context, ease of use, and low overhead is preferred, while Pandas is as big as 4MB and contains hundreds of potentially useful functions.
Getting the source¶
Source code is hosted in github. You can get it using git client:
$ git clone http://github.com/chfw/pyexcel.git
Installation¶
You can install it via pip:
$ pip install pyexcel
For individual excel file formats, please install them as you wish:
Plugin | Supported file formats | Dependencies | Python versions | Comments |
---|---|---|---|---|
pyexcel | csv, csvz [1], tsv, tsvz [2] | pyexcel-io | 2.6, 2.7, 3.3, 3.4, pypy | |
xls | xls, xlsx(read only), xlsm(read only) | xlrd, xlwt | 2.6, 2.7, 3.3, 3.4, pypy | supports reading xlsx as well |
xlsx | xlsx | openpyxl | 2.6, 2.7, 3.3, 3.4, pypy | |
ods3 | ods | ezodf, lxml | 2.6, 2.7, 3.3, 3.4 | |
ods | ods (python 2.6, 2.7) | odfpy | 2.6, 2.7 | |
text | json, rst, mediawiki,latex, grid, etc. | tabulate | 2.6, 2.7, 3.3, 3.4, pypy | writing to files only |
Please import them before you start to access the desired file formats:
from pyexcel.ext import plugin
or:
import pyexcel.ext.plugin
pyexcel | pyexcel-io | xls | xlsx | ods | ods3 | text |
---|---|---|---|---|---|---|
v0.1.7 | 0.0.6 | 0.0.7 | 0.0.6 | 0.0.6+ | 0.0.8 | 0.0.3 |
v0.1.6 | 0.0.5 | 0.0.7 | 0.0.6 | 0.0.6+ | 0.0.8 | 0.0.3 |
v0.1.5 | 0.0.4 | 0.0.7 | 0.0.6 | 0.0.6 | 0.0.8 | 0.0.2 |
v0.1.4 | 0.0.3 | 0.0.6 | 0.0.5 | 0.0.5 | 0.0.7 | 0.0.2 |
v0.1.3 | 0.0.2 | 0.0.3-0.0.5 | 0.0.2-0.0.4 | 0.0.4 | 0.0.5-0.0.6 | 0.0.2 |
v0.1.2 | 0.0.2 | 0.0.3-0.0.5 | 0.0.2-0.0.4 | 0.0.4 | 0.0.5-0.0.6 | 0.0.2 |
v0.1.1 | 0.0.2 | 0.0.3-0.0.5 | 0.0.2-0.0.4 | 0.0.4 | 0.0.5-0.0.6 | 0.0.2 |
v0.0.10 | 0.0.2 | 0.0.3-0.0.5 | 0.0.2-0.0.4 | 0.0.4 | 0.0.5-0.0.6 | 0.0.2 |
v0.0.9 | 0.0.1 | 0.0.2 | 0.0.1 | 0.0.3 | 0.0.4 | 0.0.2 |
v0.0.8 | n/a | 0.0.1 | n/a | 0.0.2 | 0.0.2+ | 0.0.1 |
v0.0.7 | n/a | 0.0.2 | 0.0.2 | n/a | ||
v0.0.6 | 0.0.2 | 0.0.2 |
Usage¶
Suppose you want to process the following excel data :
Name | Age |
---|---|
Adam | 28 |
Beatrice | 29 |
Ceri | 30 |
Dean | 26 |
Here are the example usages:
>>> import pyexcel as pe
>>> import pyexcel.ext.xls # import it to handle xls file
>>> import pyexcel.ext.xlsx # import it to handle xlsx file
>>> records = pe.get_records(file_name="your_file.xls")
>>> for record in records:
... print("%s is aged at %d" % (record['Name'], record['Age']))
Adam is aged at 28
Beatrice is aged at 29
Ceri is aged at 30
Dean is aged at 26
Design¶
Tutorial¶
- Sheet: Data Access
- Sheet: Data manipulation
- Sheet: Data filtering
- Sheet: Data conversion
- How to obtain records from an excel sheet
- How to get an array from an excel sheet
- How to save an python array as an excel file
- How to get a dictionary from an excel sheet
- How to obtain a dictionary from a multiple sheet book
- How to save a dictionary of two dimensional array as an excel file
- How to an excel sheet to a database using SQLAlchemy
- How to open an xls file and save it as csv
- How to open an xls file and save it as xlsx
- How to open a xls multiple sheet excel book and save it as csv
- Sheet: Formatting
- Book: Sheet operations
- Work with excel files
- Work with excel files in memory
Cook book¶
- Recipies
- Update one column of a data file
- Update one row of a data file
- Merge two files into one
- Select candidate columns of two files and form a new one
- Merge two files into a book where each file become a sheet
- Merge all excel files in directory into a book where each file become a sheet
- Split a book into single sheet files
- Extract just one sheet from a book
- Loading from other sources