import re


def get_summary_val(fname, vname):
    """Gets value of a summary variable from file 'fname' and 
    variable 'vname' in line of text
    Returns value and unit"""
    
    with open(fname, encoding='utf-16-le') as file:
        p = re.compile(vname + r'[ \w\.\,\n\(\)\/]*: +(\d+([.,]+[\de-]+)?)\,?\s+([\w\/]+)', re.IGNORECASE | re.UNICODE)
        m = p.search(file.read())

        # Check the desired summary value was found
        if m is None:
            print('No ' + vname + ' was found. Check the Tristar file and/or regular expression.')
            return [0, '']

    return [vname, m.group(3), float(m.group(1).replace(',', '.'))]