{"id":6905,"library":"tableschema","title":"Table Schema","description":"A utility library for working with Table Schema in Python, enabling validation, inference, and manipulation of tabular data based on the Table Schema standard. It is actively maintained with frequent releases, currently at version 1.21.0. An important notice indicates that the broader Frictionless Framework offers a more complete data solution, extending `tableschema`'s functionality.","status":"active","version":"1.21.0","language":"en","source_language":"en","source_url":"https://github.com/frictionlessdata/tableschema-py","tags":["table schema","data validation","schema","frictionless data","data processing","tabular data"],"install":[{"cmd":"pip install tableschema","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for fetching remote schema and data sources.","package":"requests"},{"reason":"Used for parsing and handling various date and time formats.","package":"python-dateutil"},{"reason":"Underpins data loading capabilities for various formats (CSV, Excel, etc.), though often implicitly handled by `Table`.","package":"tabulator"}],"imports":[{"symbol":"Table","correct":"from tableschema import Table"},{"symbol":"Schema","correct":"from tableschema import Schema"},{"symbol":"Field","correct":"from tableschema import Field"},{"symbol":"validate","correct":"from tableschema import validate"},{"symbol":"infer","correct":"from tableschema import infer"}],"quickstart":{"code":"import os\nfrom tableschema import Table, Schema\n\n# Create dummy data and schema files for demonstration\ndata_csv_content = \"\"\"\nid,name,age\n1,Alice,30\n2,Bob,24\n3,Charlie,35\n\"\"\"\n\nschema_json_content = \"\"\"\n{\n  \"fields\": [\n    {\"name\": \"id\", \"type\": \"integer\"},\n    {\"name\": \"name\", \"type\": \"string\"},\n    {\"name\": \"age\", \"type\": \"integer\"}\n  ]\n}\n\"\"\"\n\nwith open('data.csv', 'w') as f:\n    f.write(data_csv_content)\nwith open('schema.json', 'w') as f:\n    f.write(schema_json_content)\n\n# 1. Create a Table instance with data and schema\ntable = Table('data.csv', schema='schema.json')\n\n# 2. Print schema descriptor\nprint(\"Schema Descriptor:\", table.schema.descriptor)\n\n# 3. Read and print data as keyed rows\nprint(\"\\nData Rows (keyed):\")\nfor keyed_row in table.iter(keyed=True):\n    print(keyed_row)\n\n# 4. Infer schema from data\nheaders = ['id', 'name', 'age']\nrows = [[1, 'Alice', 30], [2, 'Bob', 24], [3, 'Charlie', 35]]\ninferred_schema_descriptor = Schema.infer(rows, headers)\nprint(\"\\nInferred Schema Descriptor:\", inferred_schema_descriptor)\n\n# Clean up dummy files\nos.remove('data.csv')\nos.remove('schema.json')","lang":"python","description":"This quickstart demonstrates how to initialize a `Table` with data and a schema, iterate through its rows, and infer a schema from raw data. It creates temporary `data.csv` and `schema.json` files to provide a runnable example."},"warnings":[{"fix":"Review the `v1.0` migration guide and update API calls and parameter usage according to the new patterns. It is highly recommended to pin version ranges (e.g., `tableschema>=1.0,<2.0`) to avoid unexpected major version updates.","message":"Version `1.0` introduced significant breaking changes, including API renames (e.g., `tableschema.push/pull_resource` to `tableschema.Table`, `tableschema.model` to `tableschema.Schema`, `tableschema.types` to `tableschema.Field`) and changes in parameter signatures for `Field.cast/test_value`.","severity":"breaking","affected_versions":"<1.0"},{"fix":"For new projects or if advanced data management features are needed, explore migrating to or directly using the Frictionless Framework for a more comprehensive solution. Existing `tableschema` implementations should continue to work as expected.","message":"The `tableschema` library, while functional, is part of the broader Frictionless Data ecosystem. The Frictionless Framework (a separate library) provides extended and improved `tableschema` functionality as a more complete data solution. While existing `tableschema` code is not breaking, users are encouraged to consider the Frictionless Framework for new projects or future enhancements.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To validate data against a schema, load the data using `Table` with a specified `schema` and then iterate through the data. Validation errors will be raised during iteration if the data does not conform to the schema (especially in strict mode). Use `Table.iter()` which handles casting and validation.","message":"The `validate` function (e.g., `tableschema.validate`) is designed to validate a Table Schema *descriptor* itself, not to validate *data* against a given schema. Passing data directly to `validate` will not perform data validation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always specify a version range for `tableschema` in your `requirements.txt` or `setup.py` (e.g., `tableschema>=1.0,<2.0`) to ensure predictable dependency behavior and prevent automatic upgrades to potentially breaking major versions.","message":"The library uses semantic versioning, meaning major versions (e.g., v1.x.x to v2.x.x) can introduce breaking changes. Relying on `tableschema` without a version constraint in your `requirements.txt` can lead to unexpected breakages when new major versions are released.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}