tablib

tablib 0.11.2 : Python Package Index

$ pip install tablib
import tablib

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')

# 行のスライス
print(data[:2])
[('John', 'Adams', 90), ('George', 'Washington', 67)]

# 列の表示
print(data['first_name'])
['John', 'George', 'Henry']

# 行削除
del data[1]

# JSON出力
print(data.json)

# YAML出力
print(data.yaml)

# CSV出力
print(data.csv)

# EXCEL出力
with open('people.xls', 'wb') as f:
     f.write(data.xls)