如何使用 JMP Zip Archive 命令解压缩在我之前提出的问题中,我询问是否可以解压缩文件。我读过一篇博客(使用 FILENAME ZIP 解压缩并读取 SAS 中的数据文件 - SAS Dummy ),但目前我很难使用 JSL 来跟踪它。
我有一个文件夹,里面有 150 个压缩文件夹。每个文件夹都有一个设备名称,后跟订单分数,然后是日期(即设备 X_2016_07_20.zip)。我想用设备名称创建一个新文件夹(我可以开始工作)。我可以打开一个 zip 文件夹并查看其中的所有不同文件,但我不知道如何解压缩(甚至复制)到新文件夹。有人可以帮我一下吗?
这是我到目前为止所拥有的:
directory = Pick Directory();
filesInDirectory = Files In Directory( directory );
nFiles = N Items( filesInDirectory ); //get number of zip files in directory
For( i = 1, i <= nFiles, i++,
fileName = filesInDirectory;
pos = Contains( fileName, "_" );
deviceName = Left( fileName, pos - 1 ); //get the device name
subDir = directory || deviceName;
//Create Directory(subDir); //eventually create a new sub directory
za = Open( directory || fileName, zip );
dirlist = za << dir;
Show( dirlist ) // see all contents of zipped folder
;
);
回复:如何使用 JMP Zip Archive 命令解压缩我遵循上面的示例代码,但是当我尝试读取 zip 文件的内容时,我得到了空数据。
例如,file1.csv 压缩到 file1.zip,我正在尝试从 file1.zip 读取 file1.csv
您能指出我的代码有什么问题吗?
za = Open( unzip_file_list[1], zip);
dirlist = za << 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.
txt = za << read( full_path);
回复:如何使用 JMP Zip Archive 命令解压缩<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />欢迎/感谢,以及后期跟进:加载压缩数据可能也会有帮助。
回复:如何使用 JMP Zip Archive 命令解压缩太感谢了!我绝对把它复杂化了。也很好的解释。
回复:如何使用 JMP Zip Archive 命令解压缩下一行使用 zip 存档对象 za 从存档中读取成员。像这样的东西:
za = Open( "$desktop\test.zip", zip );
dirlist = za << dir;
Show( dirlist ); // see all contents of zipped folder
// dirlist = {"fft.jmp", "fft2.jsl"};
For( i = 1, i <= N Items( dirlist ), i++,
If( Right( dirlist, 4 ) == ".jmp" /*binary data*/,
blob = za << read( dirlist, Format( blob ) );
Save Text File( "$desktop\deleteme_" || dirlist, blob );
);
If( Right( dirlist, 4 ) == ".jsl" /*text data*/,
text = za << read( dirlist );
Save Text File( "$desktop\deleteme_" || dirlist, text );
);
);
有两个示例(以粗体显示),因为 zip 文件可能包含二进制数据(本例中为 JMP 数据表)或纯文本(JMP 脚本)。二进制数据不能存储在 JSL 字符串中,但 BLOB 可以。下一行 saveTextFile 可以理解字符串和 BLOB(并且将保存 BLOB 的二进制文件,无论其名称如何)。您不应该依赖 zip 文件中成员的顺序,特别是如果有人可能编辑/添加/删除了其中的成员。
(我假设您想要提取成员,而不是将 .zip 文件复制到另一个 .zip 文件。您无需打开 zip 文件即可完成此操作。)
编辑:如果您只是复制文本文件,您也可以使用 BLOB。如果你想处理JSL中的文本,BLOB会让事情变得更困难。
回复:如何使用 JMP Zip Archive 命令解压要获取相应的条目,您必须使用 i 作为索引,例如dirlist[i]而不是dirlist
那么上面的代码就可以很好地运行。
za = Open( "$desktop\test.zip", zip );
dirlist = za << dir;
For( i = 1, i <= N Items( dirlist ), i++,
blob = za << read( <FONT color="#339966"><STRONG>dirlist[i]</STRONG></FONT>, Format( blob ) );
);
回复:如何使用 JMP Zip Archive 命令解压RP = Run Program( Executable( "C:\Program Files\WinRAR\WinRAR.exe" ), Options( {"e -or C:\1\abc.7z C:\2"} ) );