Read meta data from Little Leonardo data header rows

    Args
    ----
    path_dir: str
        Parent directory containing lleo data files
    tag_model: str
        Little Leonardo tag model name
    tag_id: str, int
        Little Leonardo tag ID number

    Returns
    -------
    meta: dict
        dictionary with meta data from header lines of lleo data files

def read_meta(path_dir, tag_model, tag_id):
    '''Read meta data from Little Leonardo data header rows

    Args
    ----
    path_dir: str
        Parent directory containing lleo data files
    tag_model: str
        Little Leonardo tag model name
    tag_id: str, int
        Little Leonardo tag ID number

    Returns
    -------
    meta: dict
        dictionary with meta data from header lines of lleo data files
    '''
    from collections import OrderedDict
    import os
    import yamlord

    from . import utils

    def _parse_meta_line(line):
        '''Return key, value pair parsed from data header line'''

        # Parse the key and its value from the line
        key, val = line.replace(':', '').replace('"', '').split(',')

        return key.strip(), val.strip()


    def _read_meta_all(f, meta, n_header):
        '''Read all meta data from header rows of data file'''

        # Skip 'File name' line
        f.seek(0)
        _ = f.readline()

        # Create child dictionary for channel / file
        line = f.readline()
        key_ch, val_ch = _parse_meta_line(line)
        val_ch = utils.posix_string(val_ch)
        meta['parameters'][val_ch] = OrderedDict()

        # Write header values to channel dict
        for _ in range(n_header-2):
            line = f.readline()
            key, val = _parse_meta_line(line)
            meta['parameters'][val_ch][key] = val.strip()

        return meta


    def _create_meta(path_dir, tag_model, tag_id):
        '''Create meta data dictionary'''
        import datetime
        from . import utils

        param_strs = utils.get_tag_params(tag_model)

        # Create dictionary of meta data
        meta = OrderedDict()

        # Create fields for the parameters in data directory name
        exp_name = os.path.split(path_dir)[1]
        params_tag = utils.parse_experiment_params(exp_name)
        for key, value in params_tag.items():
            meta[key] = value

        fmt = "%Y-%m-%d %H:%M:%S"
        meta['date_modified'] = datetime.datetime.now().strftime(fmt)

        meta['parameters'] = OrderedDict()

        for param_str in param_strs:
            print('Create meta entry for {}'.format(param_str))

            path_file = utils.find_file(path_dir, param_str, '.TXT')
            # Get number of header rows
            enc = utils.predict_encoding(path_file, n_lines=20)
            with open(path_file, 'r', encoding=enc) as f:
                n_header = utils.get_n_header(f)
                f.seek(0)
                meta = _read_meta_all(f, meta, n_header=n_header)

        return meta


    # Load meta data from YAML file if it already exists
    meta_yaml_path = os.path.join(path_dir, 'meta.yml')

    # Load file if exists else create
    if os.path.isfile(meta_yaml_path):
        meta = yamlord.read_yaml(meta_yaml_path)

    # Else create meta dictionary and save to YAML
    else:
        meta = _create_meta(path_dir, tag_model, tag_id)
        yamlord.write_yaml(meta, meta_yaml_path)

    return meta