<bdo id='okdJl'></bdo><ul id='okdJl'></ul>
    <tfoot id='okdJl'></tfoot>
  1. <legend id='okdJl'><style id='okdJl'><dir id='okdJl'><q id='okdJl'></q></dir></style></legend>

      <small id='okdJl'></small><noframes id='okdJl'>

    1. <i id='okdJl'><tr id='okdJl'><dt id='okdJl'><q id='okdJl'><span id='okdJl'><b id='okdJl'><form id='okdJl'><ins id='okdJl'></ins><ul id='okdJl'></ul><sub id='okdJl'></sub></form><legend id='okdJl'></legend><bdo id='okdJl'><pre id='okdJl'><center id='okdJl'></center></pre></bdo></b><th id='okdJl'></th></span></q></dt></tr></i><div id='okdJl'><tfoot id='okdJl'></tfoot><dl id='okdJl'><fieldset id='okdJl'></fieldset></dl></div>
    2. 解压缩文件而不创建临时文件

      unzip file without creating temporary files(解压缩文件而不创建临时文件)

      • <bdo id='6ax1X'></bdo><ul id='6ax1X'></ul>
      • <small id='6ax1X'></small><noframes id='6ax1X'>

          • <tfoot id='6ax1X'></tfoot>
              <legend id='6ax1X'><style id='6ax1X'><dir id='6ax1X'><q id='6ax1X'></q></dir></style></legend>
                <tbody id='6ax1X'></tbody>

              1. <i id='6ax1X'><tr id='6ax1X'><dt id='6ax1X'><q id='6ax1X'><span id='6ax1X'><b id='6ax1X'><form id='6ax1X'><ins id='6ax1X'></ins><ul id='6ax1X'></ul><sub id='6ax1X'></sub></form><legend id='6ax1X'></legend><bdo id='6ax1X'><pre id='6ax1X'><center id='6ax1X'></center></pre></bdo></b><th id='6ax1X'></th></span></q></dt></tr></i><div id='6ax1X'><tfoot id='6ax1X'></tfoot><dl id='6ax1X'><fieldset id='6ax1X'></fieldset></dl></div>
              2. 本文介绍了解压缩文件而不创建临时文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我从AWS S3下载了一个zip文件并解压缩。解压缩后,所有文件都保存在tmp/文件夹中。

                s3 = boto3.client('s3')
                
                s3.download_file('testunzipping','DataPump_10000838.zip','/tmp/DataPump_10000838.zip')
                
                with zipfile.ZipFile('/tmp/DataPump_10000838.zip', 'r') as zip_ref:
                    zip_ref.extractall('/tmp/')
                    lstNEW = zip_ref.namelist()
                

                listNEW的输出如下所示:

                ['DataPump_10000838/', '__MACOSX/._DataPump_10000838', 'DataPump_10000838/DockBooking', '__MACOSX/DataPump_10000838/._DockBooking', 'DataPump_10000838/LoadEquipment', '__MACOSX/DataPump_10000838/._LoadEquipment', ....]
                
                LoadEquipment和DockBooking是文件,但睡觉不是。是否可以在不创建这些临时文件的情况下解压缩文件?或者我可以用过滤把真正的文件发出去吗?因为稍后,我需要使用正确的文件并将其压缩。

                $item_$unixepochtimestamp.csv.gz

                是否使用压缩功能?

                推荐答案

                若要仅解压缩某些文件,您可以将列表传递给extractall

                with zipfile.ZipFile('/tmp/DataPump_10000838.zip', 'r') as zip_ref:
                    lstNEW = list(filter(lambda x: not x.startswith("__MACOSX/"), zip_ref.namelist()))
                    zip_ref.extractall('/tmp/', members=lstNEW)
                

                这些文件不是临时文件,而是MacOS在通常不支持此功能的zip文件中表示资源分叉的方式。

                这篇关于解压缩文件而不创建临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                      <tbody id='y0WLA'></tbody>
                    <i id='y0WLA'><tr id='y0WLA'><dt id='y0WLA'><q id='y0WLA'><span id='y0WLA'><b id='y0WLA'><form id='y0WLA'><ins id='y0WLA'></ins><ul id='y0WLA'></ul><sub id='y0WLA'></sub></form><legend id='y0WLA'></legend><bdo id='y0WLA'><pre id='y0WLA'><center id='y0WLA'></center></pre></bdo></b><th id='y0WLA'></th></span></q></dt></tr></i><div id='y0WLA'><tfoot id='y0WLA'></tfoot><dl id='y0WLA'><fieldset id='y0WLA'></fieldset></dl></div>
                  1. <small id='y0WLA'></small><noframes id='y0WLA'>

                      <legend id='y0WLA'><style id='y0WLA'><dir id='y0WLA'><q id='y0WLA'></q></dir></style></legend>
                      • <tfoot id='y0WLA'></tfoot>
                          <bdo id='y0WLA'></bdo><ul id='y0WLA'></ul>