get archive & untar in memory

PHOTO EMBED

Fri Sep 30 2022 08:20:48 GMT+0000 (Coordinated Universal Time)

Saved by @quaie #python

import requests
from io import BytesIO
import tarfile
import openpyxl as op
url = "https://url/files.tar.gz".format(_name.lower())
    r1 = requests.get(url, stream=True, verify=False)
    #print(_config, r1.status_code)
    if (_config and r1.status_code == 200):
        try:    
            tar = tarfile.open(fileobj=BytesIO(r1.content))
            bb = tar.extractfile('output/risks.xlsx').read()
            wb = op.load_workbook(filename=BytesIO(bb))
            ws = wb.worksheets[0]
            _data = ws.values
            columns = next(_data)[0:]
            df = pd.DataFrame(_data, columns=columns)
            df['Application'] = _name.upper()
            df['ST'] = _config
            _final = _final.append(df[1:])
content_copyCOPY

get a remote file, untar and do smth with it - all in memory