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

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…

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
...
1 Like

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 =)

Hi,
are there any improvements in the pipeline?
If there are more than 5 columns it is hard to handle.
The same problem occurs, trying to all values (columns) of a row/line to variable in a loop (while).
At the moment it is necessary to use 10 statements for on csv file. And there are 2 csv files to use.