Frage

I am using R.2.15.2 on Windows 7 and I cannot unzip a .gz file stored on the network. I am also using gnuwin32 (if it helps)

The file is seen, so the location is ok

system("ls")
file1.bla.gz
file2.bla.gz
file3.bla.gz
...

R) unzip("./file1.bla.gz")
Message d'avis :
In unzip("./file1.bla.gz") :
erreur 1 lors de l'extraction d'un fichier zip

R) untar("./file1.bla.gz")
/usr/bin/tar: This does not look like a tar archive
/usr/bin/tar: Skipping to next header

Using the function unzip is nor working, it looks like it is only dealing with .zip files. Not sure if the problem lies in the network or if I call It wrongly...

How can I extract this file ?

EDIT: The following worked

system(" \"C:\\Program Files\\7-Zip\\7z.exe\" e -y file1.bla.gz")

And gunzip from R.utils is even better thanks to @Paul Hiemstra

War es hilfreich?

Lösung

You can use gzfile to access the content of a gzip compressed file, for example:

read.table(gzfile("/tmp/foo.csv.gz")) 

where foo.csv.gz is a gzip compressed csv file. I got this form @DirkEddelbuettel's answer in this post.

If your goal is to extract the file, you can use the gunzip function from the R.utils package. See this R-help post.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top