tabulator-py
============
`|Travis| <https://travis-ci.org/frictionlessdata/tabulator-py>`_
`|Coveralls| <https://coveralls.io/r/frictionlessdata/tabulator-py?branch=master>`_
`|PyPi| <https://pypi.python.org/pypi/tabulator>`_
`|Gitter| <https://gitter.im/frictionlessdata/chat>`_
A utility library that provides a consistent interface for reading
tabular data.
Getting Started
---------------
Installation
~~~~~~~~~~~~
To get started (under development):
::
$ pip install tabulator
Simple interface
~~~~~~~~~~~~~~~~
Fast access to the table with ``topen`` (stands for ``table open``)
function:
::
from tabulator import topen, processors
with topen('path.csv', with_headers=True) as table:
for row in table:
print(row)
print(row.get('header'))
For the most use cases ``topen`` function is enough. It takes the
``source`` argument:
``<scheme>://path/to/file.<format>`` and uses corresponding ``Loader``
and ``Parser`` to open and start to iterate over the table. Also user
can pass ``scheme`` and ``format`` explicitly as function arguments. The
last ``topen`` argument is ``encoding`` - user can force Tabulator to
use encoding of choice to open the table.
Read more about ``topen`` -
`documentation <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/topen.py>`_.
Function ``topen`` returns ``Table`` instance. We use context manager to
call ``table.open()`` on enter and ``table.close()`` when we exit: -
table can be iterated like file-like object returning row by row - table
can be read row by bow using ``readrow`` method (it returns row tuple) -
table can be read into memory using ``read`` function (return list or
row tuples) with ``limit`` of output rows as parameter. - headers can be
accessed via ``headers`` property - table pointer can be set to start
via ``reset`` method.
Read more about ``Table`` -
`documentation <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/table.py>`_.
In the example above we use ``processors.Headers`` to extract headers
from the table (via ``with_headers=True`` shortcut). Processors is a
powerfull Tabulator concept. Parsed data goes thru pipeline of
processors to be updated before returning as table row.
Read more about ``Processor`` -
`documentation <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/processors/api.py>`_.
Read a processors tutorial -
`tutorial <https://github.com/frictionlessdata/tabulator-py/blob/master/docs/processors.md>`_.
Advanced interface
~~~~~~~~~~~~~~~~~~
To get full control over the process you can use more parameters. Below
all parts of Tabulator are presented:
::
from tabulator import topen, processors, loaders, parsers
table = topen('path.csv',
loader_options={'encondig': 'utf-8'},
parser_options={'delimeter': ',', quotechar: '|'},
loader_class=loaders.File,
parser_class=parsers.CSV,
iterator_class=CustomIterator,
table_class=CustomTable)
table.add_processor(processors.Headers(skip=1))
headers = table.headers
contents = table.read(limit=10)
print(headers, contents)
table.close()
Also ``Table`` class can be instantiated by user (see documentation).
But there is no difference between it and ``topen`` call with extended
list of parameters except ``topen`` also calls the ``table.open()``
method.
Design Overview
---------------
Tabulator uses modular architecture to be fully extensible and flexible.
It uses loosely coupled modules like ``Loader``, ``Parser`` and
``Processor`` to provide clear data flow.
.. figure:: docs/diagram.png
:align: center
:alt: diagram
diagram
Documentation
-------------
API documentation is presented as docstrings: - High-level: -
`topen <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/topen.py>`_
- Core elements: -
`Row <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/row.py>`_
-
`Table <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/table.py>`_
-
`Iterator <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/iterator.py>`_
- Plugin elements: - `Loader
API <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/loaders/api.py>`_
- `Parser
API <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/parsers/api.py>`_
- `Processor
API <https://github.com/frictionlessdata/tabulator-py/blob/master/tabulator/processors/api.py>`_
Contributing
------------
Please read the contribution guideline:
`How to Contribute <CONTRIBUTING.md>`_
Thanks!
.. |Travis| image:: https://img.shields.io/travis/frictionlessdata/tabulator-py/master.svg
.. |Coveralls| image:: http://img.shields.io/coveralls/frictionlessdata/tabulator-py.svg?branch=master
.. |PyPi| image:: https://img.shields.io/pypi/v/tabulator.svg
.. |Gitter| image:: https://img.shields.io/gitter/room/frictionlessdata/chat.svg
没有合适的资源?快使用搜索试试~ 我知道了~
Python库 | tabulator-0.3.12.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 143 浏览量
2022-04-15
22:05:02
上传
评论
收藏 18KB GZ 举报
温馨提示
共63个文件
py:47个
txt:4个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:tabulator-0.3.12.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
tabulator-0.3.12.tar.gz (63个子文件)
tabulator-0.3.12
MANIFEST.in 110B
PKG-INFO 7KB
tabulator
topen.py 3KB
processors
strict.py 1KB
headers.py 939B
__init__.py 343B
schema.py 1KB
api.py 1KB
loaders
text.py 1KB
stream.py 1KB
web.py 2KB
__init__.py 356B
file.py 1KB
api.py 1KB
errors.py 294B
table.py 4KB
iterator.py 4KB
row.py 1KB
helpers.py 2KB
__init__.py 302B
VERSION 7B
parsers
json.py 2KB
excelx.py 1KB
__init__.py 359B
excel.py 1KB
api.py 2KB
csv.py 2KB
tabulator.egg-info
PKG-INFO 7KB
requires.txt 114B
not-zip-safe 1B
SOURCES.txt 2KB
top_level.txt 16B
dependency_links.txt 1B
tests
system
test_topen.py 6KB
__init__.py 0B
module
test_topen.py 3KB
processors
test_schema.py 401B
test_headers.py 404B
__init__.py 0B
test_strict.py 401B
test_iterator.py 387B
test_table.py 378B
loaders
__init__.py 0B
test_text.py 954B
test_file.py 1KB
test_web.py 1KB
__init__.py 0B
test_row.py 487B
test_errors.py 404B
test_helpers.py 2KB
parsers
test_excelx.py 1KB
test_csv.py 1KB
test_json.py 1KB
__init__.py 0B
test_excel.py 1KB
tox.ini 392B
setup.cfg 88B
setup.py 2KB
LICENSE.md 1KB
Makefile 445B
README.md 5KB
.tox
py
lib
python2.7
site-packages
tabulator
VERSION 7B
pylintrc 282B
共 63 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功