import re


def namecore(infile):
    """
    Returns the "core" of the input file name, for use in output files.
    """
    name = infile.split('/')[-1]
    if re.search('.csv$', name):
        return(re.sub('.csv$', '', name))
    return(re.sub('.tsv.gz$', '', name))