aboutsummaryrefslogtreecommitdiffstats
path: root/python/intex/common.py
blob: 65bae4a0102fd37e98ed1d00dbf043a6610b250a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os


def sanitize_float(intex_float):
    try:
        intex_float = intex_float.replace(",", "")
        if " " in intex_float:  # case of combo notes
            return float(intex_float.split(" ")[0])
        if "(" in intex_float:
            return -float(intex_float[1:-1])
        else:
            return float(intex_float)
    except (AttributeError, ValueError):
        return intex_float