Skip to content

Commit

Permalink
[setcol-expr] show true number set
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Oct 1, 2024
1 parent 61b3e91 commit b59b745
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion visidata/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ def setValuesFromExpr(self, rows, expr):
'Set values in this column for *rows* to the result of the Python expression *expr* applied to each row.'
compiledExpr = compile(expr, '<expr>', 'eval')
vd.addUndoSetValues([self], rows)
nset = 0
for row in Progress(rows, 'setting'):
# Note: expressions that are only calculated once, do not need to pass column identity
# they can reference their "previous selves" once without causing a recursive problem
try:
v = self.sheet.evalExpr(compiledExpr, row)
self.setValue(row, v)
nset += 1
except Exception as e:
vd.exceptionCaught(e)

self.recalc()
vd.status('set %d values = %s' % (len(rows), expr))
vd.status(f'set {nset} values = {expr}')


@Sheet.api
Expand Down

0 comments on commit b59b745

Please sign in to comment.