与表格格式数据有关的 Python 库 Tablib

码农软件 · 软件分类 · Python开发工具 · 2019-11-12 15:59:02

软件介绍

Tablib 是一个与表格格式数据有关的 Python 库,允许导入、导出、管理表格格式数据。

特性

    1 导出/导入格式

  • Excel (Sets + Books)

  • JSON (Sets + Books)

  • YAML (Sets + Books)

  • HTML (Sets)

  • TSV (Sets)

  • CSV (Sets)

    2 数据操作

  • 切片

  • 定义动态列

  • 过滤

  • 格式化

示例

准备数据

headers = ('first_name', 'last_name')

data = [
    ('John', 'Adams'),
    ('George', 'Washington')
]

data = tablib.Dataset(*data, headers=headers)

添加新行

data.append(('Henry', 'Ford'))

添加新的一列

data.append_col((90, 67, 83), header='age')

导出json

>>> print data.json
[
  {
    "last_name": "Adams",
    "age": 90,
    "first_name": "John"
  },
  {
    "last_name": "Ford",
    "age": 83,
    "first_name": "Henry"
  }
]

导出xls文件

with open('grades.xls', 'wb') as f:
    f.write(tests.xls)

本文地址:https://codercto.com/soft/d/18836.html

Designing Data-Intensive Applications

Designing Data-Intensive Applications

Martin Kleppmann / O'Reilly Media / 2017-4-2 / USD 44.99

Data is at the center of many challenges in system design today. Difficult issues need to be figured out, such as scalability, consistency, reliability, efficiency, and maintainability. In addition, w......一起来看看 《Designing Data-Intensive Applications》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具