zipToolsPy

バージョン 1.2.1 (26.8 KB) 作成者: Konrad
provides basic tools to read content from zip files
ダウンロード: 62
更新 2022/6/10

zipToolsPy

A Matlab interface for the zipfile python module to provide basic tools to read content from zip files.

Functions

Overview:

  • zip_getContent: Returns the content of a zip file.
  • zip_readlines: Reads lines from a zipped text file.
  • zip_extract: Extracts specific files from a zip file.

zip_getContent

content = zip_getContent(zipFile)  

Returns the content of a zip file.

Input

  • zipFile
    Name of the zip file. <char, string>

Output

  • content
    containing information for each file in zipFile.
    Fields:
    • file_name
    • file_size
    • compress_size
    • date_time

zip_readlines

[lines, offset] = zip_readlines(zipFile, txtFileName, nLines, offset)  

Reads lines in a zip-compressed text file without unpacking the whole file.

Input

  • zipFile
    Name of the zip file. <char, string>
  • txtFileName
    Name of the compressed text file. <char, string>
  • nLines
    Number of lines to read (optional, default: 1).
  • offset
    Position (in bytes) to start reading (optional, default: 0).
  • password
    Password for encrypted zip files (optional). Pass an empty string if zipFile is not encrypted. <char, string>

Output

  • lines
    Cellstring of lines read from txtFile. A cell is empty for empty lines (containing only \n [and \r]) and contains false if there were lines requested beyond EOF. I.e. numel(lines) will allways be equal to nLines but if nLines exceeds the number of lines in the text file, the corresponding cells will contain false.

  • offset
    Position (in bytes) where we stopped reading. offset can be reused as input to continue reading on the next line.
    Cave: Complexity for seeking in zip files is O(offset), i.e. reading line by line like this would be inefficient:

     offset0 = 0; offset = offset0;
     nLines = 100;
     lines = cell(nLines,1);
     for li = 1:nLines
         [lines(li), offset] = zip_readlines(zipFile, txtFileName, 1, offset);
     end
    

    On each interation all data unti li has to be decompressed. So instead do:

      lines = zip_readlines(zipFile, txtFileName, nLines, offset0);  
    

zip_extract

extracted = zip_extract(zipFile, extrctFiles, outPath, password)  

Extracts compressed files from a zip file.

Input

  • zipFile
    Name of the zip file. <char, string>
  • extrctFiles
    Name(s) of the compressed file(s) that should be extracted. Specify '/all' (case insensitive) to extract all files. <char, string, cellstring>
  • outPath
    Path to extract file(s) to. Non-existing directories will be created (optional). <char, string>
  • password
    Password for encrypted zip files (optional). Pass an empty string if zipFile is not encrypted. <char, string>

Output

  • extracted
    Path of the extraced file(s).

引用

Konrad (2024). zipToolsPy (https://github.com/f-k-s/zipToolsPy/releases/tag/v1.2.1), GitHub. に取得済み.

MATLAB リリースの互換性
作成: R2022a
R2014b 以降のリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
謝辞

ヒントを得たファイル: ZipFile, py_addpath(directory, MATLAB_too)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.2.1

See release notes for this release on GitHub: https://github.com/f-k-s/zipToolsPy/releases/tag/v1.2.1

1.2.0

See release notes for this release on GitHub: https://github.com/f-k-s/zipToolsPy/releases/tag/v1.2.0

1.1.0

See release notes for this release on GitHub: https://github.com/f-k-s/zipToolsPy/releases/tag/v1.1.0

1.0.1

See release notes for this release on GitHub: https://github.com/f-k-s/zipToolsPy/releases/tag/v1.0.1

1.0.0

この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。