def tofloat(v):
    """Check and convert a string to a real number"""
    try:
        return float(v) if v != '.' else v
    except ValueError:
        raise ValueError('Could not convert %s to float' % v)