allanbatista
11/9/2015 - 4:18 PM

Convert numeric integer or float delimited by comma in float delimited by point

Convert numeric integer or float delimited by comma in float delimited by point

# Convert numeric integer or float delimited by comma in float delimited by point
def convert_float(string_val)
  flt = string_val.gsub(',','.')
  
  if flt.count('.') > 1
    Float(flt[0..flt.rindex('.')-1].gsub('.','') + flt[flt.rindex('.')..flt.length])
  else
    Float(flt)
  end
end