`static` opens its own scope, so outside of it the variable is not defined. You
can instead use a `static` expression and assign it to a `const` variable like
so (and in principle just directly call `toTable` instead of having `v2` and
`v3` separately, unless you need `v2` itself somewhere):
import std/[parseutils, strutils, tables]
const v2 = static:
let v1 = "data.csv".slurp.splitLines
var res = newSeq[(string, uint)]()
for pair in v1:
let splitted = split(pair, ',')
if len(splitted) > 1:
res.add((splitted[0], splitted[1].parseUint))
res
const v3 = v2.toTable
echo v3
Run
(note that you could keep the name `v2` inside of the `static` block, but I
changed it for clarity)