.tgz のファイルを開いて読み取る方法

tarfile はZipとは違うアプローチが必要

import tarfile

workpath = '/tmp/test.tgz'
filename = 'test1.tsv'

with tarfile.open(workpath) as tfile:

    if filename not in tfile.getnames():
        raise Exception('No such file %s' % filename)

    with tfile.extractfile(filename) as fp:
        for row in fp:
            print(row, end='')