TickerScrape/items.py
def curr_str_to_int(cur_str, symbol='$'):
    '''Convert a currency string-formatted number into a float.'''

    num_strs = ['thousand', 'million', 'billion', 'trillion']
    str_num_1 = None
    try:
        if not cur_str[0].isdigit():
            symbol = cur_str[0]
        for x in num_strs:
            if x in cur_str.lower():
                str_num_1 = cur_str.lower().replace(x, '').replace(',', '').replace(symbol, '')
                # str_num_1 = [cur_str.replace(x, '') for x in num_strs if x in cur_str.lower()]
        if not str_num_1:
            str_num_1 = cur_str.replace('M', '').replace('B', '').replace(
                'T', '').replace(',', '').replace(symbol, '')
        if 'm' in cur_str.lower():
            fl_num = float(str_num_1) * 1000000
        elif 'b' in cur_str.lower():
            fl_num = float(str_num_1) * 1000000000
        elif 'thousand' in cur_str.lower():
            fl_num = float(str_num_1) * 1000
        elif ('T' in cur_str) or ('trillion' in cur_str.lower()):
            fl_num = float(str_num_1) * 1000000000000
        elif [i.isdigit() for i in str_num_1]:
            fl_num = float(str_num_1)
        else:
            fl_num = None
    except:
        fl_num = None
    return fl_num
Convert a currency string-formatted number into a float.
Convert a currency string-formatted number into a float.
Convert a currency string - formatted number into a float .
def curr_str_to_int(cur_str, symbol='$'):
    num_strs = ['thousand', 'million', 'billion', 'trillion']
    str_num_1 = None
    try:
        if not cur_str[0].isdigit():
            symbol = cur_str[0]
        for x in num_strs:
            if x in cur_str.lower():
                str_num_1 = cur_str.lower().replace(x, '').replace(',', '').replace(symbol, '')
        if not str_num_1:
            str_num_1 = cur_str.replace('M', '').replace('B', '').replace(
                'T', '').replace(',', '').replace(symbol, '')
        if 'm' in cur_str.lower():
            fl_num = float(str_num_1) * 1000000
        elif 'b' in cur_str.lower():
            fl_num = float(str_num_1) * 1000000000
        elif 'thousand' in cur_str.lower():
            fl_num = float(str_num_1) * 1000
        elif ('T' in cur_str) or ('trillion' in cur_str.lower()):
            fl_num = float(str_num_1) * 1000000000000
        elif [i.isdigit() for i in str_num_1]:
            fl_num = float(str_num_1)
        else:
            fl_num = None
    except:
        fl_num = None
    return fl_num
def curr_str_to_int ( cur_str , symbol = '$' ) : num_strs = [ 'thousand' , 'million' , 'billion' , 'trillion' ] str_num_1 = None try : if not cur_str [ 0 ] . isdigit ( ) : symbol = cur_str [ 0 ] for x in num_strs : if x in cur_str . lower ( ) : str_num_1 = cur_str . lower ( ) . replace ( x , '' ) . replace ( ',' , '' ) . replace ( symbol , '' ) if not str_num_1 : str_num_1 = cur_str . replace ( 'M' , '' ) . replace ( 'B' , '' ) . replace ( 'T' , '' ) . replace ( ',' , '' ) . replace ( symbol , '' ) if 'm' in cur_str . lower ( ) : fl_num = float ( str_num_1 ) * 1000000 elif 'b' in cur_str . lower ( ) : fl_num = float ( str_num_1 ) * 1000000000 elif 'thousand' in cur_str . lower ( ) : fl_num = float ( str_num_1 ) * 1000 elif ( 'T' in cur_str ) or ( 'trillion' in cur_str . lower ( ) ) : fl_num = float ( str_num_1 ) * 1000000000000 elif [ i . isdigit ( ) for i in str_num_1 ] : fl_num = float ( str_num_1 ) else : fl_num = None except : fl_num = None return fl_num
Convert a currency string-formatted number into a float.
Convert a currency string - formatted number into a float .
'''Convert a currency string-formatted number into a float.''' # str_num_1 = [cur_str.replace(x, '') for x in num_strs if x in cur_str.lower()]
cur_str
symbol