{"id":13339487,"url":"https://github.com/tdast/tdast","last_synced_at":"2025-08-11T01:36:49.929Z","repository":{"id":144056745,"uuid":"293594194","full_name":"tdast/tdast","owner":"tdast","description":"Tabular Data Abstract Syntax Tree","archived":false,"fork":false,"pushed_at":"2020-09-13T20:28:07.000Z","size":14,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T14:42:41.664Z","etag":null,"topics":["ast","csv","io","syntax-tree","tabular-data","tdast","unist"],"latest_commit_sha":null,"homepage":"https://github.com/tdast","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdast.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-07T17:44:47.000Z","updated_at":"2021-07-05T07:26:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"1b8edc6e-d675-4e33-8a1d-d0e110d52a4f","html_url":"https://github.com/tdast/tdast","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tdast/tdast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdast%2Ftdast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdast%2Ftdast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdast%2Ftdast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdast%2Ftdast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdast","download_url":"https://codeload.github.com/tdast/tdast/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdast%2Ftdast/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269818803,"owners_count":24480074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","csv","io","syntax-tree","tabular-data","tdast","unist"],"created_at":"2024-07-29T19:20:03.990Z","updated_at":"2025-08-11T01:36:49.891Z","avatar_url":"https://github.com/tdast.png","language":null,"readme":"# ![tdast](./logo.png)\n\n**T**abular **D**ata **A**bstract **S**yntax **T**ree format.\n\n---\n\n**tdast** is a specification for representing tabular data as an abstract\n[syntax tree][syntax-tree].\nIt implements the **[unist][]** spec.\n\nThis document may not be released.  See [releases][] for released documents.\n\n## Contents\n\n*   [Introduction](#introduction)\n    *   [Where this specification fits](#where-this-specification-fits)\n    *   [Scope](#scope)\n*   [Nodes](#nodes)\n    *   [`Parent`](#parent)\n    *   [`Literal`](#literal)\n    *   [`Table`](#table)\n    *   [`Row`](#row)\n    *   [`Cell`](#cell)\n    *   [`Column`](#column)\n*   [Glossary](#glossary)\n*   [List of utilities](#list-of-utilities)\n*   [Related](#related)\n*   [License](#license)\n\n## Introduction\n\nThis document defines a format for representing tabular data as an [abstract syntax\ntree][syntax-tree].  This specification is written in the style of other [syntax-tree][] specs, for potential incorporation into the ecosystem in the future.  Development started in September 2020.\n\n### Where this specification fits\n\ntdast extends [unist][], a format for syntax trees, and benefits from its\n[ecosystem of utilities][unist-utilities].\n\ntdast relates to [JavaScript][] in that it has an [ecosystem of\nutilities][unist-utilities] for working with compliant syntax trees in\nJavaScript.  However, tdast is not limited to JavaScript and can be used in other programming\nlanguages.\n\ntdast relates to the [unified][] project in that tdast syntax trees follow the [unist][] spec and is compatible with utilities throughout its ecosystem.\n\n### Scope\n\ntdast seeks to represent how tabular data from some source content (e.g. CSV, JSON), would be represented in a syntax tree.  It implements the [unist][] spec, meaning that the tree would track positional information of nodes that will be useful for remaining interoperable with unist utilities.\n\nWith associated utilities, tdast enables flexible ways to parse, transform, serialize tabular data in various content formats.  CSV, JSON, HTML tables are immediate native candidates benefiting from tdast, and future content types can be supported by implementors.\n\nWhile it is possible to perform data calculations in tdast with associated utilities, it is recommended that you work with more direct data representations of the source content for these purposes.  tdast utilites to convert to/from JS objects exist for this purpose.\n\nWhile tdast could be used to represent most tabular data, it is best used with simple cases of flat tabular data.\n\n\n## Nodes\n\n### `Parent`\n\n```ts\ninterface Parent extends UnistParent {\n  /** Array of child nodes */\n  children: Array\u003cRow | Cell | Column\u003e;\n  /** Additional data maybe attached. */\n  data?: Data;\n}\n```\n\n`Parent` ([`UnistParent`][dfn-unist-parent]) is an abstract node containing other nodes (said to be children).\n\nThis node is not used directly in tdast and is defined as an abstract interface.\n\n### `Literal`\n\n```ts\ninterface Literal extends UnistLiteral {\n  /** Primary data value of a literal node. Loosely typed to `any` for convenience. */\n  value: any;\n  /** Additional data maybe attached. */\n  data?: Data;\n}\n```\n\n`Literal` ([`UnistLiteral`][dfn-unist-literal]) is an abstract node in containing a value.\n\nThis node is not used directly in tdast and is defined as an abstract interface.\n\n### `Table`\n\n```ts\ninterface Table extends Parent {\n  /** Table node type. */\n  type: 'table';\n  /** Can only contain Rows for children. */\n  children: Row[];\n}\n```\n\n`Table` ([`Parent`][parent]) represents the node that holds all tabular data with [`Row`][row] nodes.\n\n`Table` can be used as the [root][dfn-unist-root] of a [tree][dfn-unist-tree], but never as a [child][dfn-unist-child].\n\n\n### `Row`\n\n```ts\ninterface Row extends Parent {\n  /** Row node type. */\n  type: 'row';\n  /** Index of Row in relation to other Rows in a Table. */\n  index: number;\n  /** Can only contain Cells or Columns for children. */\n  children: Array\u003cCell | Column\u003e;\n}\n```\n\n`Row` ([`Parent`][parent]) holds literal nodes that contain data, such as [`Column`][column] or [`Cell`][cell] nodes.\n\n`Row` contains an `index` field that tracks its relative position with other rows under a [`Table`][table].\n\n### `Cell`\n\n```ts\ninterface Cell extends Literal {\n  /** Cell node type. */\n  type: 'cell';\n  /** Tracks which Column the Cell belongs to */\n  columnIndex: number;\n  /** Tracks which Row the Cell belongs to */\n  rowIndex: number\n}\n```\n\n`Cell` ([`Literal`][literal]) represents the intersection of a [`Row`][row] and [`Column`][column] of a [`Table`][table].  This intersection information is stored on the `columnIndex` and `rowIndex` properties.\n\nIts primary data is stored on the `value` property.  `Cell` can also contain attach additional data (not relevant to tdast) under the optional `data` property.\n\n### `Column`\n\n```ts\ninterface Column extends Literal {\n  /** Column node type. */\n  type: 'column';\n  /** Display label of a column. */\n  label: string;\n  /** Index of Column in relation to other Columns in a Table. */\n  index: number;\n  /** Optional data type useful to determine data types of Cells matching the Column. */\n  dataType?: string;\n}\n```\n\n`Column` ([`Literal`][literal]) is usually reserved in the first [`Row`][row] of a [`Table`][table].\n\n`Column` contains an `index` field that tracks its relative position with other columns under a [`Table`][table].  Its primary data is represented in the `value` property.  It should have a display `label` specified as a string.\n\n`Column` can optionally specify the `dataType` property, which informs the data types applied to [`Cell`s][cell] in a [`Row`][row].\n\n\n## Glossary\n\n- **`ast`**: a data structure representing source content as an abstract syntax tree.\n- **`cell`**: the intersection of a table row and column.  A cell contains data.\n- **`column`**: a table column provides definitions for cells in subsequent rows.  A column should define the `dataType` of cells under it.  The cardinality of a column is equal to the number of rows in a table.\n- **`csv`**: a common tabular data format that uses comma-separated values for delimiting values.\n- **`dataType`**: refers to the data type a table cell assumes.  This is usually defined by a table column.\n- **`row`**: a table row contains cells.  The cardinality of a row is equal to the number of columns in a table.  The `dataType` of each cell should assume what is prescribed by the columns.\n- **`table`**: an arrangement of data in rows and columns.\n- **`tdast`**: represent tabular data as an abstract syntax tree with tdast.\n- **`unist`**: [universal syntax tree][unist] that tdast is based on.\n\n\n## List of utilities\n\n- [`tdastscript`][tdastscript]: utility to create tdast trees.\n- [`tdast-util-from-array`][tdast-util-from-array]: transform from JS array to tdast\n- [`tdast-util-from-csv`][tdast-util-from-csv]: parse from CSV to tdast ([RFC-4180][] compliant)\n- [`tdast-util-to-array`][tdast-util-to-array]: transform tdast to JS array, which can be manipulated externally and read back with `tdast-util-from-array`.\n- [`tdast-util-to-csv`][tdast-util-to-csv]: serialize tdast to CSV ([RFC-4180][] compliant)\n- [`tdast-util-to-hast-table`][tdast-util-to-hast-table]: transform tdast to a [hast][] table node\n- [`tdast-util-to-html-table`][tdast-util-to-html-table]: serialize tdast to a HTML table\n- [`tdast-util-to-json`][tdast-util-to-json]: serialize tdast to JSON (array form)\n- [`tdast-util-to-markdown-table`][tdast-util-to-markdown-table]: serialize tdast to a markdown table\n\n\n## Related\n- [unist][]: Universal Syntax Tree format\n- [tdastscript][]: utility to create tdast trees.\n\n\n## License\n\n[CC-BY-4.0][license] © [Chris Zhou][author]\n\n\u003c!-- Definitions --\u003e\n[cell]: #cell\n[column]: #column\n[literal]: #literal\n[parent]: #parent\n[row]: #row\n[table]: #table\n\n[author]: https://chrisrzhou.io\n[dfn-unist-child]: https://github.com/syntax-tree/unist#child\n[dfn-unist-literal]: https://github.com/syntax-tree/unist#literal\n[dfn-unist-parent]: https://github.com/syntax-tree/unist#parent\n[dfn-unist-root]: https://github.com/syntax-tree/unist#root\n[dfn-unist-tree]: https://github.com/syntax-tree/unist#tree\n[hast]: https://github.com/syntax-tree/hast\n[license]: https://creativecommons.org/licenses/by/4.0/\n[javascript]: https://www.ecma-international.org/ecma-262/9.0/index.html\n[releases]: https://github.com/tdast/tdast/releases\n[rfc-4180]: https://tools.ietf.org/html/rfc4180\n[syntax-tree]: https://github.com/syntax-tree/unist#syntax-tree\n[tdastscript]: https://github.com/tdast/tdastscript\n[tdast-util-from-array]: https://github.com/tdast/tdast-util-from-array\n[tdast-util-from-csv]: https://github.com/tdast/tdast-util-from-csv\n[tdast-util-to-array]: https://github.com/tdast/tdast-util-to-array\n[tdast-util-to-csv]: https://github.com/tdast/tdast-util-to-csv\n[tdast-util-to-hast-table]: https://github.com/tdast/tdast-util-to-hast-table\n[tdast-util-to-html-table]: https://github.com/tdast/tdast-util-to-html-table\n[tdast-util-to-json]: https://github.com/tdast/tdast-util-to-json\n[tdast-util-to-markdown-table]: https://github.com/tdast/tdast-util-to-markdown-table\n[unified]: https://github.com/unifiedjs/unified\n[unist]: https://github.com/syntax-tree/unist\n[unist-utilities]: https://github.com/syntax-tree/unist#list-of-utilities\n[xast]: https://github.com/syntax-tree/xast\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdast%2Ftdast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdast%2Ftdast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdast%2Ftdast/lists"}