zip

ZIP is a standard file compression format. The DolphinDB zip plugin can decompress ZIP files and compress files into ZIP format. The plugin is developed based on Minizip and Zipper libraries.

Installation (with installPlugin)

Required server version: DolphinDB 2.00.10 or higher

OS: Windows, Windows JIT, Linux, Linux JIT, and Linux ABI.

Installation Steps:

(1) Use listRemotePlugins to check plugin information in the plugin repository.

Note: For plugins not included in the provided list, you can install through precompiled binaries or compile from source. These files can be accessed from our GitHub repository by switching to the appropriate version branch.

login("admin", "123456")
listRemotePlugins()

(2) Invoke installPlugin for plugin installation

installPlugin("zip")

(3) Use loadPlugin to load the plugin before using the plugin methods.

loadPlugin("zip")

Method References

unzip

Syntax

unzip(zipFileName, [outputDir], [callback], [zipEncode], [password])

Parameters

  • zipFileName: A STRING scalar indicating the absolute path to the ZIP file.
  • outputDir (optional): A STRING scalar indicating the absolute path the file will be extracted to. If it is unspecified or specified as "", the ZIP file will be extracted to its current directory. Note that existing files with the same name under the directory will be replaced.
  • callback (optional): A callback function that only takes one STRING type parameter.
  • zipEncode (optional): A STRING scalar indicating the encoding of file names in the ZIP file. This parameter ensures that the extracted file paths are correctly encoded. Currently, only gbk and utf-8 are supported. On Windows OS, it defaults to gbk, while on Linux OS, it defaults to utf-8. For example, to extract files from a ZIP file encoded in utf-8 on Windows OS, specify zipEncode as "utf-8".
  • password (optional): A STRING scalar indicating the password of the ZIP file.

Details

Extract files from a ZIP file. Return a STRING vector containing the file paths to the extracted files.

The extracted files can be processed with the specified callback function. For the ZIP file containing multiple files, the callback function is executed each time a member file is extracted for optimal performance.

Examples

filenames = zip::unzip("/path_to_zipFile/test.zip", "/path_to_output/", func);

print(filenames)
["/path_to_output/test.csv"]

zip

Syntax

zip(zipFileName, fileOrFolderPath, [compressionLevel], [password])

Parameters

  • zipFileName: A STRING scalar indicating the absolute path to the ZIP file.
  • fileOrFolderPath: A STRING scalar indicating the path to the folder or file to be compressed.
  • compressionLevel (optional): A STRING scalar indicating the level of compression. It supports two options: "faster" for faster compression speed and "better" for higher compression rates.
  • password (optional): A STRING scalar indicating the password of the ZIP file.

Details

Compress the specified folder or file into ZIP format.

Examples

zip::zip("/hdd1/commit/DolphinDBPlugin/zip/test/test.zip", "/hdd1/commit/DolphinDBPlugin/zip/data")