I've been trying to compute the delta of a column of integer values. That is, from column "A" create a new column "delta_A". Something like...
| A | delta_A
| - | -
| 1 | ⌀
| 2 | 1
| 4 | 2
| 8 | 4
Running addcol-delta results in new column appearing, but only with ! characters in red color in each cell (which I believe represents an exception occured)
However, it's not clear to me how I determine what the exception actually was (running 'error-recent' command says "no error"), so I can't provide much more information. There is presumably some problem in the calculation of the expr attribute of the ColumnExpr object:
https://github.com/saulpw/visidata/blob/stable/plugins/rownum.py#L59
As a sanity test, setting this expr attrbute to a static value instead, such as "hello", will successfully set each cell in the column to "hello".
VisiData v2.0.1
Hi @uoee, you almost have it! Use 'error-cell' (z Ctrl+E) to show the error contained within a cell. (The error-recent command (Ctrl+E) is for exceptions that show up on the status line.)
I'm guessing that in this case you'll see a stacktrace and the error TypeError: unsupported operand type(s) for -: 'str' and 'str'. This is because A is an untyped column with string values which can't be subtracted. If you set the type of column A with 'type-int' (#) or another numeric type, it should work.
Hi, thanks for the response. I should have mentioned that I had already set the column to integer type, so the issue was not string subtraction, but in fact subtraction of a None value (which I identified from the error-cell command you referred to, thanks).
I was going to look into the problem further, but then updating Visidata from the pip release to use your latest commit dd3aaa4 on the develop branch made the error resolve itself anyway.
Most helpful comment
Hi, thanks for the response. I should have mentioned that I had already set the column to integer type, so the issue was not string subtraction, but in fact subtraction of a
Nonevalue (which I identified from theerror-cellcommand you referred to, thanks).I was going to look into the problem further, but then updating Visidata from the pip release to use your latest commit dd3aaa4 on the develop branch made the error resolve itself anyway.