Using excel value with loop - not printing values - printing col numbers


#1

I’m trying to read excel (csv) file and print the value of columns with condition.
But instead of excel value, printing “${!COL1}”.

Source:
{
“CreationDate”: “2018-7-3”,
“Commands”: [
{
“Command”: “csvRead”,
“Target”: “test.csv”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “no”
},
{
“Command”: “echo”,
“Target”: “${!COL${no}}”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “${!col${no}}”,
“Value”: “test”
},
{
“Command”: “echo”,
“Target”: “${test}”,
“Value”: “”
},
{
“Command”: “label”,
“Target”: “searchrow_loop”,
“Value”: “”
},
{
“Command”: “storeEval”,
“Target”: “${no}+1”,
“Value”: “no”
},
{
“Command”: “echo”,
“Target”: “${!COL${no}}”,
“Value”: “”
},
{
“Command”: “gotoIf”,
“Target”: “”${no}"!=“3"”,
“Value”: “searchrow_loop”
}
]
}

Note: test.csv contains some values…


#2

Nice idea, but a variable inside a variable is not supported yet. That is why only the inner variable gets expanded.

Solution: You can use if/endif instead:

if (${no} == 1) 
store | ${!col1} | test
endif
if (${no} == 2) 
store | ${!col2} | test
endif
if (${no} == 3) 
store | ${!col3} | test
endif
...

How to random select csv value
[error] Internal variable "!COLx" not supported - how to avoid CSV read error?
#3

Hello.
Is there any way to workaround !COLx variable for unknown amount of columns?
I mean i can have 4 to 8 columns in my work csv file.
I wanted to make a script flexible and fitting any amount of columns. Is it possible?

Can i somehow construct this variable, like this “${!COL”+storedVars[‘N’]+"}" using some command?
Or maybe call a variable via a variable?
Thanks in forward.

P.S.: nested variables would be great =)