Skip to content

Commit

Permalink
Merge pull request #2471 from saulpw/kef/typesheet
Browse files Browse the repository at this point in the history
[docs] expand TypeSheet.md
  • Loading branch information
anjakefala authored Aug 7, 2024
2 parents 66d4b3f + 5c6044a commit 253e314
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions visidata/guides/TypesSheet.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Types

Columns usually begin as untyped (`anytype`), but can be set.
Columns usually begin as untyped (`anytype`), but can be set to specific types.

- {help.commands.type-any}
- {help.commands.type-currency}
Expand All @@ -10,4 +10,34 @@ Columns usually begin as untyped (`anytype`), but can be set.
- {help.commands.type-len}
- {help.commands.type-string}

*Note*: `float` uses the decimal separator; `currency` removes non-numeric characters and parses as float; `date` parses dates into ISO8601 format; `len` formats the cell value to the length of the content.
## Type formatting

VisiData pre-set defaults for formatting types:

- `currency` removes non-numeric characters and parses the remainder as `float`.
- `date` parses dates into date object (shown as ISO8601).
- `vlen` formats the cell value to the length of the content
- `float` uses the decimal seperator, keeping two significant digits.

Change float precision with:
- {help.commands.setcol-precision-less}
- {help.commands.setcol-precision-more}

To change the default fmtstr for a type:

- {help.options.disp_currency_fmt}
- {help.options.color_currency_neg}
- {help.options.disp_date_fmt}
- {help.options.disp_float_fmt}
- {help.options.disp_int_fmt}


## Importance of typing

Certain commands behave differently depending on how the column is typed.

Grouping by a numeric column in a Frequency table can result in numeric range binning. Grouping by a string results in categorical binning.

Un-typed columns (`anytype`) often default to `string`-like behaviour. Errors when working with numerical or datetime data is often due to values being considered as strings.

For example. [:code]addcol-expr col1+col2[/] results in a concatenation of the two columns when they are `anytype`, and addition when they are numerical.

0 comments on commit 253e314

Please sign in to comment.