visidata icon indicating copy to clipboard operation
visidata copied to clipboard

Derived transposed sheet cells do not keep source column type

Open pacien opened this issue 4 months ago • 0 comments

Small description

This is a follow-up to https://github.com/saulpw/visidata/discussions/2548.

The cells in the derived transposed sheets do not seem to keep the type and formatters from the origin columns.

This is happening for example for monetary columns ($) or date columns (@).

Data to reproduce None.

Steps to reproduce

Example 1: open visidata in your home directory, then transpose that file list sheet. Notice that the "modtime" values cells are now floats instead of dates like in the source sheet.

Example 2: create a column "A/B" as the result of A/B, then assign it the monetary column type. The cells in the transposed sheet "forget" the monetary type, displaying a float instead:

#!vd -p
{"sheet": null, "col": null, "row": null, "longname": "open-file", "input": "test.tsv", "keystrokes": "o", "comment": null}
{"sheet": "test", "col": "A", "row": "", "longname": "type-currency", "input": "", "keystrokes": "$", "comment": "set type of current column to currency"}
{"sheet": "test", "col": "A", "row": "", "longname": "addcol-new", "input": "B", "keystrokes": "za", "comment": "append an empty column"}
{"sheet": "test", "col": "B", "row": "", "longname": "type-int", "input": "", "keystrokes": "#", "comment": "set type of current column to int"}
{"sheet": "test", "col": "B", "row": "", "longname": "addcol-expr", "input": "A/B", "keystrokes": "=", "comment": "create new column from Python expression, with column names as variables"}
{"sheet": "test", "col": "A/B", "row": "", "longname": "type-currency", "input": "", "keystrokes": "$", "comment": "set type of current column to currency"}
{"sheet": "test", "col": "", "row": "", "longname": "add-row", "input": "", "keystrokes": "a", "comment": "append a blank row"}
{"sheet": "test", "col": "A", "row": "0", "longname": "edit-cell", "input": "1.00", "keystrokes": "e", "comment": "edit contents of current cell"}
{"sheet": "test", "col": "B", "row": "0", "longname": "edit-cell", "input": "3", "keystrokes": "e", "comment": "edit contents of current cell"}
{"sheet": "test", "col": "", "row": "", "longname": "transpose", "input": "", "keystrokes": "Shift+T", "comment": "open new sheet with rows and columns transposed"}

Expected result

Cells should keep the same type and format as the source column.

Configuration

  • Does this issue reproduce without any plugins or configuration (using the -N CLI flag)? Yes

  • Does this issue reproduce with either the latest release, or with the develop branch? Yes on latest release (3.1.1). Didn't check develop branch.

Additional context

  • What platform and version are you using (Linux, MacOS, Windows)? Linux, NixOS

  • Which version of Python? 3.12

  • Which terminal are you using (for display and input issues)? Kitty

pacien avatar Oct 19 '24 14:10 pacien