{"id":2686,"library":"pyexcel-io","title":"Pyexcel IO","description":"Pyexcel-io is a Python library providing a unified API to read and write structured data from various file formats (CSV, TSV, and extensions like XLS, XLSX, ODS via plugins) and databases (SQLAlchemy, Django models). It focuses on data processing, not formatting, fonts, or charts. It is actively maintained with frequent minor releases.","status":"active","version":"0.6.7","language":"en","source_language":"en","source_url":"https://github.com/pyexcel/pyexcel-io","tags":["data processing","excel","csv","io","spreadsheet","tabular data"],"install":[{"cmd":"pip install pyexcel-io","lang":"bash","label":"Install pyexcel-io"}],"dependencies":[{"reason":"Required for reading 'csvz' and 'tsvz' formats. Moved to optional since v0.6.7.","package":"chardet","optional":true}],"imports":[{"symbol":"get_data","correct":"from pyexcel_io import get_data"},{"symbol":"save_data","correct":"from pyexcel_io import save_data"}],"quickstart":{"code":"import os\nfrom pyexcel_io import save_data, get_data\nfrom io import StringIO\n\n# --- Writing data to a virtual CSV file (StringIO) ---\ndata_to_write = [\n    [\"Name\", \"Age\", \"City\"],\n    [\"Alice\", 30, \"New York\"],\n    [\"Bob\", 24, \"London\"]\n]\n\noutput_stream = StringIO()\nsave_data(output_stream, data_to_write, file_type='csv')\n\n# Simulate getting content from the stream\noutput_stream.seek(0)\ncsv_content = output_stream.getvalue()\nprint(\"Generated CSV content:\\n\" + csv_content)\n\n# --- Reading data from the virtual CSV file (StringIO) ---\ninput_stream = StringIO(csv_content)\n# get_data returns a dictionary where keys are sheet names (or 'csv' for single file)\ndread_data = get_data(input_stream, file_type='csv')\n\n# Access the first (and only) sheet, usually named 'csv'\nif 'csv' in dread_data:\n    print(\"\\nRead data:\")\n    for row in dread_data['csv']:\n        print(row)\nelse:\n    print(\"Error: Could not read data from CSV stream.\")\n\n# Example with a physical file (uncomment to test locally)\n# file_name = \"example.csv\"\n# save_data(file_name, data_to_write)\n# data_from_file = get_data(file_name)\n# print(f\"\\nData from {file_name}: {data_from_file[file_name]}\")\n# os.remove(file_name) # Clean up","lang":"python","description":"This quickstart demonstrates how to use `pyexcel-io` to write tabular data to a virtual CSV file (using `StringIO`) and then read it back. The core functions `save_data` and `get_data` provide a unified interface for various data sources and formats."},"warnings":[{"fix":"Upgrade to Python 3.6 or newer, or use pyexcel-io versions lower than 0.6.0 if Python 2 or older Python 3 is necessary.","message":"Pyexcel-io v0.6.0 dropped support for Python 2 and older Python 3 versions (3.3, 3.4, 3.5). Python 3.6+ is now required.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Update existing plugins or develop new ones conforming to the new plugin interface. Review PyInstaller documentation for updated packaging instructions.","message":"The plugin interface was completely rewritten in v0.6.0, making plugins developed for older versions (e.g., v0.3.x) incompatible. This also impacts PyInstaller users requiring updated configurations.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"If reading `csvz` or `tsvz` formats, explicitly install `chardet`: `pip install chardet`.","message":"The `chardet` library, previously an implicit dependency for `csvz` and `tsvz` readers, became optional in v0.6.7. If your application relies on these formats, you may need to install `chardet` explicitly.","severity":"gotcha","affected_versions":">=0.6.7"},{"fix":"Upgrade to pyexcel-io v0.6.7 or newer. If upgrading is not possible, avoid dots in filenames or provide a file-like object instead.","message":"In versions prior to 0.6.7, pathnames containing dots ('.') could cause `file_name` errors when using `get_writer`.","severity":"gotcha","affected_versions":"<0.6.7"},{"fix":"Explicitly specify the desired plugin using the `library` parameter in `get_data` or `save_data` (e.g., `get_data(..., library='pyexcel-odsr')`), or uninstall the unwanted overlapping plugin.","message":"When multiple pyexcel plugins (e.g., `pyexcel-ods` and `pyexcel-odsr`) are installed that support the same file format, `pyexcel-io` might pick one unpredictably. This can lead to unexpected behavior or an error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Users needing to preserve such formatting or handle protected files should consider alternative libraries or pre-process/post-process files outside of pyexcel-io.","message":"Pyexcel-io specifically focuses on tabular data; it does not support reading or writing fonts, colors, charts, images, or password-protected Excel files.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For optimal memory usage with large files, prefer CSV format or plugins explicitly designed for streaming (e.g., `pyexcel-xlsxr`).","message":"While pyexcel-io supports 'streaming' for large files, many underlying plugins for formats like XLS, XLSX, and ODS (e.g., `pyexcel-xls`, `pyexcel-xlsx`, `pyexcel-ods`) still load the entire file into memory due to their zipped XML structure. Only `csv` readers, `pyexcel-xlsxr`, `pyexcel-odsr`, and `pyexcel-htmlr` truly support partial/streaming reads for memory efficiency.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}