Python的表格数据集:Tablib

jopen 10年前

Tablib是一种格式无关的表格数据集库,用Python编写的。它允许您导入,导出和处理表格数据集。高级功能包括,隔离,动态列,标签和过滤,以及无缝的格式导入和导出。

输出的格式支持:

  • Excel (Sets + Books)
  • JSON (Sets + Books)
  • YAML (Sets + Books)
  • HTML (Sets)
  • TSV (Sets)
  • CSV (Sets)
>>> data = tablib.Dataset(*[('Kenneth', 'Reitz', 23), ('Bessie', 'Monke', 22)],                            headers=['First Name', 'Last Name', 'Age'])    >>> data.json  [{"Last Name": "Reitz", "First Name": "Kenneth", "Age": 22}, {"Last Name": "Monke", "First Name": "Bessie", "Age": 21}]    >>> data.yaml  - {Age: 22, First Name: Kenneth, Last Name: Reitz}  - {Age: 21, First Name: Bessie, Last Name: Monke}    >>> data.xlsx  <censored binary data>

项目主页:http://www.open-open.com/lib/view/home/1404377881452