2018-05-29から1日間の記事一覧

.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.extr…