我希望使用R(版本3.2.2)來讀取壓縮爲.Z
文件的多個文件。我瞭解uncompress()
已在最近的版本中刪除。我非常感謝,如果任何人都可以讓我知道我可以如何使用R來解壓.Z文件的。如何解壓縮.Z文件
1
A
回答
1
我知道我遲到了這個問題,但我正在四處尋找,看看有什麼更好的建議比我們在發現您的問題時所做的更好。正如Ben所建議的那樣,調用另一個工具對於Windows來說可能是最好的選擇,Linux和OS X可以本地處理.Z文件。
下面是一個函數示例(不是我寫的,Ivan Hanigan寫的,但是我已經使用了它,所以我知道它的工作原理)在R包中檢查操作系統,然後查找7Zip如果操作系統是Windows。
https://github.com/swish-climate-impact-assessment/awaptools/blob/master/R/ZipFunctions.R
################################################################
# name:ZipFunctions.R
uncompress_linux <- function(filename)
{
print(filename)
system(sprintf('uncompress %s',filename))
}
# tries to find 7 zip exe
ExecutableFileName7Zip <- function()
{
executableName <- "C:\\Program Files\\7-Zip\\7z.exe"
if(file.exists(executableName))
{
return (executableName)
}
#other executable file names and ideas go here ...
stop("failed to find 7zip")
}
# simple function to extract 7zip file
# need to have 7zip installed
Decompress7Zip <- function(zipFileName, outputDirectory, delete)
{
executableName <- ExecutableFileName7Zip()
# fileName = GetFileName(zipFileName)
# fileName = PathCombine(outputDirectory, fileName)
# if(file.exists(fileName))
# {
# unlink(zipFileName);
# }
arguments <- paste(sep="",
"e ",
"\"", zipFileName, "\" ",
"\"-o", outputDirectory, "\" ",
"")
print(arguments)
RunProcess(executableName, arguments)
if(delete)
{
unlink(zipFileName);
}
}
+0
非常感謝您的回答。這也是我當時的工作。我想,雖然可能不是唯一的,但可能是R在Windows上處理.Z文件的最有效方式。乾杯。 – mikeqfu
1
相關問題
- 1. 解壓縮.Z文件
- 2. 解壓縮.Z文件C
- 3. 在MATLAB中解壓縮.Z文件
- 4. 如何解壓/解壓縮文件
- 5. NSIS:如何解壓7zip壓縮文件
- 6. 解壓縮Z文件,然後在腳本中刪除文件
- 7. 解壓縮(解壓縮)由.net壓縮(解壓縮)的文件.net system.io.compression.gzipstream
- 8. 解壓縮文件
- 9. 解壓縮文件
- 10. Node.js - 壓縮/解壓縮文件夾
- 11. 壓縮解壓縮的exe文件
- 12. Magick ++壓縮和解壓縮文件
- 13. 如何使用命令行解壓縮xip壓縮文件?
- 14. node.js如何流化22GB gzip壓縮文件解壓縮
- 15. 如何使用rubyzip解壓縮壓縮文件夾
- 16. 如何解壓縮已壓縮兩次的文件?
- 17. 如何解壓縮使用fusecompress/lzo壓縮的文件?
- 18. 如何在asp.net框架4.0中壓縮/解壓縮文件夾
- 19. 需要解壓縮.Z文件(奇怪的放氣)
- 20. 如何將壓縮聲音文件轉換爲解壓縮文件
- 21. 解壓縮Zip文件3.6
- 22. 空氣解壓縮文件
- 23. tomcat和解壓縮文件
- 24. Android - 解壓縮文件夾?
- 25. java解壓縮文件
- 26. 解壓縮.zip文件
- 27. 解壓縮saz文件java
- 28. 迅速解壓縮文件
- 29. BlackBerry - 解壓縮Zip文件
- 30. 解壓縮tar.gz文件
你使用的是什麼操作系統?你可能需要通過調用另一個工具來使用'system()'... https://kb.iu.edu/d/abck,http://superuser.com/questions/190053/universal-command-line -un-storage-tool-on-a-mac –
嗨,本,我使用Windows 7 – mikeqfu