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(zipFilePath, [outputDir], [callback], [zipEncoding], [password])

Parameters

  • zipFilePath: 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.
  • zipEncoding (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 zipEncoding 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(zipFilePath, fileOrFolderPath, [compressionLevel], [password])

Parameters

  • zipFilePath: 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")

setLogLevel

Syntax

zip::setLogLevel(logLevel)

Details

Sets the plugin's log level. The system prints plugin logs at the specified level and above. The default log level is INFO. Note that this function only sets the plugin's log level and does not change the DolphinDB server's log level.

Parameters

logLevel: The log level. Available values, in ascending order of severity, are DEBUG, INFO, WARNING, and ERROR.

Example

Set the log level of the zip plugin to WARNING so that only WARNING and ERROR logs are output.

zip::setLogLevel(WARNING)

getLogLevel

Syntax

zip::getLogLevel()

Details

Returns the current log level of the plugin. The return value is a STRING scalar.