saulpw / visidata

A terminal spreadsheet multitool for discovering and arranging data
http://visidata.org
GNU General Public License v3.0
7.91k stars 283 forks source link

Make `curcol` available to `setcol-expr` #2524

Closed reagle closed 1 month ago

reagle commented 1 month ago

I'm trying to move a column of {m,M,f,F} all to uppercase, I'd love to quickly do it in the current column with g= rather than create a new one via =. I understand there is a curcol object (is there a list of internal objects and functions?) but gsg=curcol.upper() fails.

gsg=gender.upper() will usually work, but I had a case yesterday where it didn't and I can't remember/replicate it this morning.

person,gender
1,F
2,M
3,m
4,M
5,f
6,f
7,m
8,M
9,m
10,f
reagle commented 1 month ago

Ah, here it is, sometimes I get TypeErrors, sometimes I don't and I don't know why. In either case, when it completes nothing has changed. I can freeze gender, but in that case I might as well use =.

https://asciinema.org/a/fQGh3zqXxgxSVrIl2pL9EalKR

anjakefala commented 1 month ago

From my testing g= is functional. The actual problem is not g=, but that the curcol variable is not available to setcol-expr (https://github.com/saulpw/visidata/issues/989).

NameError: name 'curcol' is not defined
saulpw commented 1 month ago

curcol should work in all = expression contexts now.

reagle commented 1 month ago

Confirmed, thank you.