mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 23:10:17 +00:00
80 lines
1.3 KiB
Markdown
80 lines
1.3 KiB
Markdown
Tabbed -- Pythonic Tabular Datasets
|
|
===================================
|
|
|
|
**Tabbed is under active documentation-driven development.**
|
|
|
|
Formats supported:
|
|
|
|
- JSON
|
|
- YAML
|
|
- Excel
|
|
- CSV
|
|
- CDL
|
|
|
|
Please note that this list _purposefully_ excludes XML. And it always will.
|
|
|
|
|
|
Features
|
|
--------
|
|
|
|
Convert data formats via API:
|
|
|
|
tabbed.import(filename='data.csv').export('data.json')
|
|
|
|
|
|
Convert data formats via CLI:
|
|
|
|
tabbed data.csv data.json
|
|
|
|
|
|
Populate fresh data files:
|
|
|
|
headers = ('first_name', 'last_name', 'gpa')
|
|
|
|
data = [
|
|
('John', 'Adams', 4.0),
|
|
('George', 'Washington', 2.6),
|
|
('Henry', 'Ford', 2.3)
|
|
]
|
|
|
|
data = tabbed.Data(*data, headers=headers)
|
|
|
|
# Establish file location and save
|
|
data.save('test.xls')
|
|
|
|
|
|
Intelligently add new rows:
|
|
|
|
data.addRow('Bob', 'Dylan')
|
|
# >>> Warning: Existing column count is 3
|
|
|
|
print data.headers
|
|
# >>> ('first_name', 'last_name', 'gpa')
|
|
|
|
|
|
Slice rows:
|
|
|
|
print data[0:1]
|
|
# >>> [('John', 'Adams', 4.0), ('George', 'Washington', 2.6)]
|
|
|
|
|
|
Slice columns by header:
|
|
|
|
print data['first_name']
|
|
# >>> ['John', 'George', 'Henry']
|
|
|
|
|
|
Manipulate rows by index:
|
|
|
|
data.delRow(0)
|
|
print data[0:1]
|
|
# >>> [('George', 'Washington', 2.6), ('Henry', 'Ford', 2.3)]
|
|
|
|
# Update saved file
|
|
data.save()
|
|
|
|
|
|
Export to various formats:
|
|
|
|
# Save copy as CSV
|
|
data.export('backup.csv') |