Skip to content

[RFC]: add support for pretty printing tabular data in the REPL #2067

Open

Description

Description

This RFC proposes adding support for displaying tabular data in the REPL. Possible signature:

table( data[, n] )

It could work in a manner similar to head/tail, where, if n > 0, show the first n rows, and, if n < 0, show the last n rows.

The function could also support options, such as maximum cell width (e.g., to enforce showing abbreviated cell contents (such as truncating long strings)).

If data is an array of objects, could use keys as headers. Otherwise, if array of arrays, could support providing a list of headers.

Related Issues

No.

Questions

  • Generating ASCII tables is likely to be applicable beyond just the REPL. So one question is whether the implementation for ASCII tables should live outside the REPL (e.g., in @stdlib/plot/ascii/table or similar) and then the REPL would just use that package for displaying tabular data? This probably makes sense, and we'd just need to define the API surface of the ASCII table package.
  • We should also support ndarray data.

Other

ASCII tables are fairly common, so prior art should be relatively easy to find. For example,

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

EnhancementIssue or pull request for enhancing existing functionality.JavaScriptIssue involves or relates to JavaScript.Needs DiscussionNeeds further discussion.REPLIssue or pull request specific to the project REPL.RFCRequest for comments. Feature requests and proposed changes.difficulty: 4Likely to be moderately difficult.priority: NormalNormal priority concern or feature request.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions