Skip to content

Instantly share code, notes, and snippets.

@allanbatista
Created November 9, 2015 16:18
Show Gist options
  • Save allanbatista/8a76b029ba1d6a8246d8 to your computer and use it in GitHub Desktop.
Save allanbatista/8a76b029ba1d6a8246d8 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment