我正在从Bing Reporting API加载CSV文件。文档说“报告文件已压缩;因此,您必须解压缩它才能读取报告。”,所以我保存原始文件,如示例所示,但我无法通过SharpZipLib,7Zip或WinRar来读取压缩数据。
如何解压缩Bing API报告?
答案 0 :(得分:0)
为了回答我自己的问题,我能够让SharpZipLib读取压缩数据,但只能先将其复制到可搜索的内存流。这不是任意大文件的最佳解决方案,但我有理由相信我们的具体数据不会太大。
答案 1 :(得分:0)
下载一些bing报告可能有点像一首歌 - 但流程有点像这样 -
下面是一个非常简单的例子,简单地解压缩拉链并在某个地方进行搜索 - 希望这会有所帮助,祝你好运
$zip_filepath = "location of the zip file";
$archive = new ZipArchive();
// file extension of extracted file
if ($archive->open($zip_filepath) !== true) {
throw new \Exception ("Decompress operation from ZIP file failed. Contact Ratio Rick");
}
$a = $archive->statIndex(0);
$file_name = $a['name'];
$save_path = "enter save file path";
$archive->extractTo($path . $file_name);
$archive->close();