jeudi 11 octobre 2018

Robot Framework - Remove a character ' from a String within a list?

I am trying something similliar to this question here

Remove this " $ , . " of a string in Robot Framework

But the difference with my problem is that I have a list of values, that i need parse in a json format, I am parsing a CSV file to get the values, the values come in as "' Value1'", "'Value2'", "'Value3'" and so on.

I need to get rid of the ' character from all of the values in that list so i just need "Value1", "Value2", "Value3", is that possible using robot framework ?

This is what I am trying to do

${DeviceName_list}=  create list
:FOR  ${Row_Elements}  IN RANGE  ${row_ID}  517
\  ${read_csv} =  read cell value by row  csv-staff.csv  ${row_ID}
\  log  ${read_csv}
\  ${DeviceName}  get from dictionary   ${read_csv}  DeviceName
\  append to list  ${DeviceName_list}  '${DeviceName}'
\  ${row_ID}=  evaluate   ${row_ID} + 1
set global variable  ${DeviceName_list}
log  ${DeviceName_list} # "' Value1'", "'Value2'", "'Value3'"
${DeviceName_list}=   Remove String   ${DeviceName_list}  '  ${empty}

Obviously I am getting the following error

'list' object has no attribute 'replace'

Is there a work Around to this?

Aucun commentaire:

Enregistrer un commentaire