0

I was following along this SO post on how to download and unzip a file.

url <- 'https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz'
file <- basename(url)
download.file(url, file)

tmpdir <- tempdir()
untar(file, compressed = 'gzip', exdir = tmpdir)

Everything runs fine in the above block except the last line which returns

> untar(file, compressed = 'gzip', exdir = tmpdir)
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Warning message:
In untar(file, compressed = "gzip", exdir = tmpdir) :
  ‘/usr/bin/tar -xf 'GoogleNews-vectors-negative300.bin.gz' -C '/var/folders/ll/g08vjcnd33vdhf250bbg9230fdw13f/T//RtmpAICV5a'’ returned error code 1

How can I unzip GoogleNews-vectors-negative300.bin.gz after downloading it?

Doug Fir
  • 19,971
  • 47
  • 169
  • 299
  • 2
    Are you sure it's a tar file? If it isn't, I'm guessing `untar` won't work on it. Try `R.utils::gunzip`, which is probably better suited – camille Oct 03 '18 at 03:02
  • agree with @Camille...it looks like you have a binary file (not a tarball) that was compressed with gzip. you can decompress it with `gunzip`. – Chris Oct 03 '18 at 03:03
  • @camille gunzip did the trick, thank oyu – Doug Fir Oct 03 '18 at 03:49

0 Answers0