{"id":2302,"library":"tablib","title":"Tablib: Pythonic Tabular Datasets","description":"Tablib is an MIT-licensed, format-agnostic tabular dataset library for Python, enabling Pythonic import, export, and manipulation of tabular data. It supports various formats like XLS, JSON, YAML, CSV, Pandas DataFrames, and HTML. Maintained by the Jazzband community, it is currently in version 3.9.0 and receives regular updates for Python compatibility and bug fixes.","status":"active","version":"3.9.0","language":"en","source_language":"en","source_url":"https://github.com/jazzband/tablib","tags":["tabular data","excel","csv","json","yaml","export","import","dataset","data manipulation","formats"],"install":[{"cmd":"pip install tablib","lang":"bash","label":"Core installation"},{"cmd":"pip install \"tablib[all]\"","lang":"bash","label":"Installation with all optional format dependencies"},{"cmd":"pip install \"tablib[xlsx, pandas, yaml]\"","lang":"bash","label":"Installation with specific optional format dependencies"}],"dependencies":[{"reason":"For OpenDocument Spreadsheet (ODS) format support.","package":"odfpy","optional":true},{"reason":"For Excel 07+ Spreadsheet (XLSX) format support.","package":"openpyxl","optional":true},{"reason":"For Pandas DataFrame export/import support.","package":"pandas","optional":true},{"reason":"For YAML format support.","package":"pyyaml","optional":true},{"reason":"For CLI table format export support.","package":"tabulate","optional":true},{"reason":"For Legacy Excel Spreadsheet (XLS) import support.","package":"xlrd","optional":true},{"reason":"For Legacy Excel Spreadsheet (XLS) export support.","package":"xlwt","optional":true}],"imports":[{"symbol":"Dataset","correct":"from tablib import Dataset"},{"note":"Used for handling multiple Dataset objects, typically for multi-sheet Excel files.","symbol":"Databook","correct":"from tablib import Databook"}],"quickstart":{"code":"import tablib\n\n# Create a new Dataset\ndata = tablib.Dataset()\n\n# Add headers\ndata.headers = ['First Name', 'Last Name', 'Age']\n\n# Add rows\ndata.append(['Kenneth', 'Reitz', 22])\ndata.append(['Bessie', 'Monke', 20])\n\n# Add a new column with data\ndata.append_col([True, False], header='Is Student')\n\nprint(\"CSV Export:\")\nprint(data.export('csv'))\n\nprint(\"\\nJSON Export:\")\nprint(data.export('json'))\n\n# Example of saving to a file (uncomment to run)\n# with open('output.xlsx', 'wb') as f:\n#     f.write(data.export('xlsx'))\n# print(\"\\nData exported to output.xlsx\")","lang":"python","description":"This quickstart demonstrates how to create a `Dataset` object, add headers, append rows, add a new column, and then export the data to different formats like CSV and JSON. It also includes a commented-out example for exporting to an XLSX file."},"warnings":[{"fix":"Review code using `lpush` or `rpush` on `Row` objects when upgrading to 2.0.0+ to ensure the intended prepend/append behavior.","message":"The logic for `Row.lpush` and `Row.rpush` methods was reversed in Tablib 2.0.0. In versions 1.x, `lpush` appended and `rpush` prepended, which was non-standard. This was corrected in 2.0.0.","severity":"breaking","affected_versions":"1.x -> 2.0.0"},{"fix":"Ensure your project uses Python 3.6+ for Tablib 3.x.","message":"Python 2 support was dropped with Tablib 1.0.0. Python 3.5 support was dropped with Tablib 3.0.0.","severity":"breaking","affected_versions":"<1.0.0 for Python 2, <3.0.0 for Python 3.5"},{"fix":"If upgrading from pre-1.0.0 and encountering `ImportError` for format-specific modules, use `pip install \"tablib[all]\"` or install specific format dependencies like `pip install \"tablib[xlsx]\"`.","message":"Starting with Tablib 1.0.0, all format dependencies became optional. Previously, they might have been installed by default. To install all possible format dependencies, you now need to use `pip install \"tablib[all]\"`.","severity":"breaking","affected_versions":"<1.0.0 -> 1.0.0+"},{"fix":"Always open CSV files with `newline=''` when exporting Tablib's CSV output to a file: `with open('output.csv', 'w', newline='') as f: f.write(data.export('csv'))`.","message":"When exporting CSV files on Windows, if you don't specify `newline=''` when opening the file in write mode, Excel might display a blank line between each row.","severity":"gotcha","affected_versions":"All versions (Python's `csv` module behavior)"},{"fix":"For datasets exceeding 65,000 rows, export to XLSX (`data.export('xlsx')`) rather than XLS (`data.export('xls')`).","message":"The legacy XLS format (Excel 97-2003) has a limitation of 65,000 rows. If you are dealing with larger datasets, you should use the XLSX format instead.","severity":"gotcha","affected_versions":"All versions when using XLS"},{"fix":"If encountering issues with large XLSX/ODS files not importing fully, consider checking the spreadsheet source or, if possible, disable `read_only` (though this might increase memory usage for large files).","message":"When importing XLSX or ODS files with `read_only=True` (which is the default for XLSX), Tablib relies on the spreadsheet declaring correct dimensions. Some programs might generate files with incorrect dimensions, leading to incomplete reads.","severity":"gotcha","affected_versions":"All versions with lazy reading"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}