Reputation: 229
Currently working with Robot Framework List.
I have a LIST like this ['Thu 2/22/2018', ' ', '-', '0.0000', '0', '', 'Fri 2/23/2018', '0', '-', '0.0000', '0', '+20 hr 28 min', 'Sat 2/24/2018', '37', '37', '0.0000', '37', '-10 hr 23 min']
I want to convert ${SPACE},${EMPTY} and - values to '0'. I am trying with below code but i am getting these errors
ValueError: Cannot convert index ' ' to an integer.
ValueError: Cannot convert index '-' to an integer.
ValueError: Cannot convert index '' to an integer.
here is the code
:FOR ${x} IN @{OnlyList}
\ Log ${x} console=true
\ run keyword if '${x}'== '${SPACE}' Collections.set list value ${OnlyList} ${x} 0
\ run keyword if '${x}'== '-' Collections.set list value ${OnlyList} ${x} 0
\ run keyword if '${x}'== '${EMPTY}' Collections.set list value ${OnlyList} ${x} 0
Not sure how to convert. Pl help.
Upvotes: 1
Views: 502
Reputation: 1582
Set List Value
takes index as the second argument.
${i} Set Variable ${0}
:FOR ${x} IN @{OnlyList}
\ Log ${x} console=true
\ run keyword if '${x}'== '${SPACE}' Collections.set list value ${OnlyList} ${i} 0
\ run keyword if '${x}'== '-' Collections.set list value ${OnlyList} ${i} 0
\ run keyword if '${x}'== '${EMPTY}' Collections.set list value ${OnlyList} ${i} 0
\ ${i} Set Variable ${i+1}
Log ${OnlyList} console=true
Upvotes: 6