2019-04-07 18:26:20 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ParseFloat(input string) (float64, error) {
|
|
|
|
|
|
|
|
clean := strings.TrimSpace(input)
|
2019-08-03 20:50:41 +00:00
|
|
|
clean = strings.Replace(clean, ",", ".", -1) // replace decimal comma with decimal point
|
2019-04-07 18:26:20 +00:00
|
|
|
|
|
|
|
if strings.Contains(clean, "\n") {
|
|
|
|
lastIndex := strings.LastIndex(clean, "\n")
|
|
|
|
clean = clean[lastIndex+1:]
|
|
|
|
}
|
|
|
|
|
|
|
|
return strconv.ParseFloat(clean, 64)
|
|
|
|
}
|