Welcome, Jedox enthusiasts! In today’s tutorial, we’ll dive into file compression and extraction using Jedox, specifically, the powerful FILE.unzip function. As a prerequisite, we will need to create some folders in our backend which will be used for testing purposes.

  1. Connect to your backend with some tool like WinSCP.
  2. If you don’t have your credentials check the cloud console.
  3. If you do not have access to the cloud console – contact cloud support.
  4. Once you are connected create 2 folders in /etl_data/files
    /etl_data/files/For Zipping
    /etl_data/files/For Unzipping
  5. In “For Zipping” folder add Excel files 1,2,3.
  6. In the “For Unzipping” folder add two zipped files “ZippedWithoutPass” and “ZippedWithPass”.
  7. The password for unzipping is in the file pass. (Download the whole project at the bottom of the page)
zip folders

unzipped folders

At the same time we need to create some directory and file locations in Jedox which will be used as a path for the following scenarios:

Zip directories

Scenario 1: Compressing a File into a Zip Folder

The first scenario we’ll explore is the basic compression of a file into a zipped folder. This straightforward process is great when dealing with large datasets or multiple files.
Copy the code to the groovy Job and adjust the folder names.
// Jedox ETL Code
FILE.zip(“path/to/source/file.txt”, “path/to/target/folder/archive.zip”);
This code will compress “file.txt” into a zip folder named “archive.zip.” Simple, right? Let’s move on to the next level.

Scenario 2: Compressing a File in a Password-Protected Zip Folder

Security is paramount, and Jedox provides a solution for password-protecting your zipped folders. Here’s how you can do it:
Copy the code to the groovy Job and adjust the folder names.
// Jedox ETL Code
FILE.zip(“path/to/source/file.txt”, “path/to/target/folder/secure_archive.zip”, “YourPassword”);
In this example, “file.txt” is compressed into “secure_archive.zip” with the added protection of the password “YourPassword.” Your data stays safe and sound!

Scenario 3: Uncompressing a File from a Zipp Folder

Now, let’s reverse the process and extract a file from a zipped folder:
Copy the code to the Groovy Job and adjust the folder names.
// Jedox ETL Code
FILE.unzip(“path/to/source/archive.zip”, “path/to/target/folder/”);
This code will unzip “archive.zip” into the specified target folder. Simple yet effective—your data is ready for action.

Scenario 4: Uncompressing a File from a Password-Protected Zip Folder

What if your zipped folder is protected by a password? No worries, Jedox has you covered:

Copy the code to the groovy Job and adjust the folder names.
// Jedox ETL Code
FILE.unzip(“path/to/source/secure_archive.zip”, “path/to/target/folder/”, “YourPassword”);
Just provide the correct password (“YourPassword” in this case), and Jedox will gracefully unzip the content into the designated folder.

Conclusion


Congratulations! You’ve now mastered the FILE.unzip function in Jedox, opening up a world of possibilities for efficient data handling and storage in the File System. It’s important to note that these techniques are specifically designed for the Jedox File System only so far.

Using different libraries when working with Groovy is always fun but have in mind that Jedox will enable Groovy Sandbox starting from November 2024. List of allowed libraries can be found here.

Stay tuned for more Jedox tips and tricks on jedox4beggines.com, where we empower beginners to become Jedox masters!

Happy Zipping 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!