import gzip


def get_ascii_header_variables(filename, gz=False):
    """return the header and variables of an ascii file"""
    if gz:
        with gzip.open(filename, 'rt') as fname:
            header = fname.readline().split()
            fname.readline()
            variables = fname.readline().split()
    else:
        with open(filename) as fname:
            header = fname.readline().split()
            fname.readline()
            variables = fname.readline().split()
    return header, variables