def insert_preext(filename, sub_ext):
    """
    Insert a pre-extension before file extension

    E.g:    'file.csv' -> 'file.xyz.csv'
    """
    fs = filename.split('.')
    fs.insert(-1, sub_ext)
    fn = '.'.join(fs)
    return fn