<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to unzip using JMP Zip Archive Commands in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19590#M17851</link>
    <description>&lt;P&gt;the next line uses the zip archive object, za, to read a member from the archive.&amp;nbsp; something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;za = Open( "$desktop\test.zip", zip );
dirlist = za &amp;lt;&amp;lt; dir;
Show( dirlist ); // see all contents of zipped folder

// dirlist = {"fft.jmp", "fft2.jsl"};

For( i = 1, i &amp;lt;= N Items( dirlist ), i++,
&amp;nbsp; If( Right( dirlist, 4 ) == ".jmp" /*binary data*/,
&amp;nbsp; blob = za &amp;lt;&amp;lt; read( dirlist, Format( blob ) );
&amp;nbsp; Save Text File( "$desktop\deleteme_" || dirlist, blob );
&amp;nbsp; );
&amp;nbsp; If( Right( dirlist, 4 ) == ".jsl" /*text data*/,
&amp;nbsp; text = za &amp;lt;&amp;lt; read( dirlist );
&amp;nbsp; Save Text File( "$desktop\deleteme_" || dirlist, text );
&amp;nbsp; );
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there are two examples, in bold, because a zip file might contain binary data (a JMP data table in this case) or plain text (a JMP script).&amp;nbsp; The binary data can't be stored in a JSL string, but a BLOB will work.&amp;nbsp; The next line, saveTextFile, understands both strings and BLOBs (and will save a binary file for a BLOB, in spite if its name).&amp;nbsp; You should not depend on the order of the members in the zip file, especially if someone might have edited/added/deleted members from them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I'm assuming you want to extract the members, not copy the .zip file to another .zip file.&amp;nbsp; You could do that without opening the zip file at all.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: you can use BLOB for text files too, if you are just copying them.&amp;nbsp; If you want to process the text in JSL, BLOB will make it harder.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 14:47:23 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2019-07-18T14:47:23Z</dc:date>
    <item>
      <title>How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19589#M17850</link>
      <description>&lt;P&gt;In an earlier question I asked, I asked if it was possible to unzip files.&amp;nbsp; I read a blog (&lt;A title="http://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" href="http://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_blank" rel="noopener"&gt;Using FILENAME ZIP to unzip and read data files in SAS - The SAS Dummy&lt;/A&gt;), but at the moment I am having a hard time following it using JSL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a folder with 150 zipped folders in it.&amp;nbsp; Each folder has a device name, followed by an order score, then the date (ie. Device X_2016_07_20.zip).&amp;nbsp; I want to create a new folder with the device name (which I can get working).&amp;nbsp; I can get open a zip folder and see all the different files within, but I can not figure out how to unzip (or even copy) to the new folder.&amp;nbsp; Can someone please give me a hand?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I have so far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;directory = Pick Directory();
filesInDirectory = Files In Directory( directory );
nFiles = N Items( filesInDirectory );&amp;nbsp; //get number of zip files in directory

For( i = 1, i &amp;lt;= nFiles, i++, 


&amp;nbsp;	fileName = filesInDirectory;

&amp;nbsp;	pos = Contains( fileName, "_" );
	deviceName = Left( fileName, pos - 1 ); //get the device name
&amp;nbsp;	subDir = directory || deviceName;
&amp;nbsp; //Create Directory(subDir); //eventually create a new sub directory

&amp;nbsp;	za = Open( directory || fileName, zip );
	dirlist = za &amp;lt;&amp;lt; dir;
	Show( dirlist ) // see all contents of zipped folder

	;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 14:46:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19589#M17850</guid>
      <dc:creator>natalie_</dc:creator>
      <dc:date>2019-07-18T14:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19590#M17851</link>
      <description>&lt;P&gt;the next line uses the zip archive object, za, to read a member from the archive.&amp;nbsp; something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;za = Open( "$desktop\test.zip", zip );
dirlist = za &amp;lt;&amp;lt; dir;
Show( dirlist ); // see all contents of zipped folder

// dirlist = {"fft.jmp", "fft2.jsl"};

For( i = 1, i &amp;lt;= N Items( dirlist ), i++,
&amp;nbsp; If( Right( dirlist, 4 ) == ".jmp" /*binary data*/,
&amp;nbsp; blob = za &amp;lt;&amp;lt; read( dirlist, Format( blob ) );
&amp;nbsp; Save Text File( "$desktop\deleteme_" || dirlist, blob );
&amp;nbsp; );
&amp;nbsp; If( Right( dirlist, 4 ) == ".jsl" /*text data*/,
&amp;nbsp; text = za &amp;lt;&amp;lt; read( dirlist );
&amp;nbsp; Save Text File( "$desktop\deleteme_" || dirlist, text );
&amp;nbsp; );
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there are two examples, in bold, because a zip file might contain binary data (a JMP data table in this case) or plain text (a JMP script).&amp;nbsp; The binary data can't be stored in a JSL string, but a BLOB will work.&amp;nbsp; The next line, saveTextFile, understands both strings and BLOBs (and will save a binary file for a BLOB, in spite if its name).&amp;nbsp; You should not depend on the order of the members in the zip file, especially if someone might have edited/added/deleted members from them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I'm assuming you want to extract the members, not copy the .zip file to another .zip file.&amp;nbsp; You could do that without opening the zip file at all.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: you can use BLOB for text files too, if you are just copying them.&amp;nbsp; If you want to process the text in JSL, BLOB will make it harder.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 14:47:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19590#M17851</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-07-18T14:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19591#M17852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much!&amp;nbsp; I was definitely over complicating it.&amp;nbsp; Excellent explanation, too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2016 14:01:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19591#M17852</guid>
      <dc:creator>natalie_</dc:creator>
      <dc:date>2016-07-21T14:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19592#M17853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Welcome/thanks, and a late follow-up: &lt;A href="https://community.jmp.com/blogs/id/1263" target="_blank"&gt;Load Compressed Data&lt;/A&gt; might be helpful too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 10:07:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/19592#M17853</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2016-11-09T10:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/217862#M43561</link>
      <description>&lt;P&gt;I am following above example code, but I got empty data when I try to read the contents of zip file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, file1.csv zipped to file1.zip, and I am trying to read file1.csv from file1.zip&lt;/P&gt;
&lt;P&gt;Would you please point me what is wrong in my code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;za = Open( unzip_file_list[1], zip);
dirlist = za &amp;lt;&amp;lt; dir;

// below line correctly giving me file1.csv
show(dirlist);

// below two lines correctly gives me full file path.
full_path = directory || dirlist[1];
show(full_path);

// below line returns "Empty()" in log windows.&amp;nbsp;
txt = za &amp;lt;&amp;lt; read( full_path);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 14:47:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/217862#M43561</guid>
      <dc:creator>youngkic</dc:creator>
      <dc:date>2019-07-18T14:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/767321#M94751</link>
      <description>&lt;P&gt;to get the respective entries, you have to use i as an index, e.g.&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dirlist[i]&lt;/FONT&gt; instead of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dirlist&lt;BR /&gt;&lt;/FONT&gt;then the code from above works great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;za = Open( "$desktop\test.zip", zip );
dirlist = za &amp;lt;&amp;lt; dir;

For( i = 1, i &amp;lt;= N Items( dirlist ), i++,
  blob = za &amp;lt;&amp;lt; read( &lt;FONT color="#339966"&gt;&lt;STRONG&gt;dirlist[i]&lt;/STRONG&gt;&lt;/FONT&gt;, Format( blob ) );

);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 07:22:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/767321#M94751</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-06-22T07:22:27Z</dc:date>
    </item>
    <item>
      <title>回复： How to unzip using JMP Zip Archive Commands</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/767339#M94752</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Extract JSL I used myself:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;RP = Run Program( Executable( "C:\Program Files\WinRAR\WinRAR.exe" ), Options( {"e -or C:\1\abc.7z C:\2"} ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jun 2024 13:24:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-unzip-using-JMP-Zip-Archive-Commands/m-p/767339#M94752</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2024-06-20T13:24:40Z</dc:date>
    </item>
  </channel>
</rss>

