Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

.csv file to .zip file format conversion

Avatar

Level 2

Hello Team,

 

 

I'm looking to convert a single .csv file into a .zip format and then transfer it to SFTP. Could you please assist me with this?

 

 

Thank you.

 

 

Regards, Ankita Vishe

7 Replies

Avatar

Community Advisor

Hi @AnkitaV3131 ,

 

You can use the below Command to convert .csv file generated using Data Extraction activity to .zip file

 

Please run this command using Java script activity.

 

execCommand('zip -r -j '+vars.directorypathZipFileIsPlaced+' '+vars.filename+'');

 

Here vars.filename refers to the .CSV File generated.

 

Regards,

Pravallika.

 

Avatar

Level 2

Hi Pravallika,

Thanks for your response!!

Can you just help me with the "vars.directorypathZipFileIsPlaced". What will be the value for this or what will in place of this?

Regards,
Ankita Vishe

Avatar

Community Advisor

Hi @AnkitaV3131 

 

As Lakshmi has mentioned, "vars.directorypathZipFileIsPlaced" is the directory path where you want to create/place the zipped file created from the .CSV file.

 

For reference, please see the following link.

 

Regards

Akshay

Avatar

Level 2

Hi Akshay,

Thank You!

 

I have tried both the command.


1) execCommand('zip -r -j '+vars.zipFilename+' /sftp/test/incoming/Zip'+' '+vars.filename+'');

First one is throwing an error. Also, first time when I executed this it worked but the file is not placed.

 

2)execCommand('zip '+vars.zipFilename+' '+vars.filename+'');

Second one is generating the file but with "compressed zip folder" not compressed zip file.

Regards,
Ankita Vishe

Avatar

Community Advisor

Hi @AnkitaV3131 

 

Are you giving the full file path like "SFTPC:\Users\akshayanand\Downloads\OneDrive_1_5-8-2024.zip" ?

 

Something like the below code

execCommand('zip -r -j /sftp/test/incoming/Zip/fileName.zip '+sourceDirectoryPath+'');

 

Regards

Akshay

Avatar

Administrator

Hi @AnkitaV3131,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa

Avatar

Level 1

I have generated one .csv file and now trying to convert it to zip file and I am using the below script for that but it is giving error (BAS-010076 Cannot execute command 'zip -r -j \\12.34.56\\ABC\test.zip \\12.34.56\\ABC\test.csv' (err=2, the system cannot find the file specified.) . Can anyone help with this?

vars.filename = "\\\\12.34.56\\ABC\\test.csv";[This is the file I already generated through data extraction activity]
vars.directorypathZipFileIsPlaced = "\\\\12.34.56\\ABC\\test.zip";

execCommand('zip -r -j '+vars.directorypathZipFileIsPlaced+' '+vars.filename+'');

I tried with vars.filename = "test.csv"; as well but it didn't work.