csv - Read string as variable RUBY -
i pulling following string csv file, cell a1, , storing variable:
#{collector_id}
so, cell a1 reads #{collector_id}
, , code this:
test = #excel_cell_a1
however, if this:
puts test
i this:
#{collector_id}
i need #{collector_id}
read actual variable collector_id
, not code using call variable. possible?
thanks help. using ruby 1.9.3.
you can use sub
or gsub
replace expected input values:
collector_id = "foo" test = '#{collector_id}' test.sub("\#{collector_id}", "#{collector_id}") #=> "foo"
i avoid use of eval
(or @ least sanity check running) reduce risk of running arbitrary code receive csv file.
Comments
Post a Comment