1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

tar.gzファイルのダウンロードから解凍保存をメモリ上で実施したい

Posted at

やりたいこと

tar.gzファイルを外部からダウンロードし、メモリ上で解凍。
解凍したファイルを任意のディレクトリに保存。(tar.gzファイルは保存しない)

実現方法

import requests
import tarfile
import io

with tarfile.open(fileobj=io.BytesIO(requests.get('tar.gzの取得先URL').content)) as tarf:
    tarf.extractall('保存先ディレクトリ', members=tarf)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?