0

I am trying to download an Excel file (xls) from the Australia Bureau of Statistics in r with the following code. However, everytime I try to run the line with the read_excel command my session crashes.

library(readxl)

target <- 'http://www.ausstats.abs.gov.au/ausstats/meisubs.nsf/LatestTimeSeries/6202001/$FILE/6202001.xls'

path <- paste0(getwd(),"/","6202001.xls")

download.file(target, destfile = path)

#read_excel(path = path) << problem line

I think it might have something to do with the excel file pop-up when you go to put the link into a browser and download it that way, but I'm not sure!

Do I need to change the file before I go to read it at all?

Any help would be great.

Dom
  • 1,043
  • 2
  • 10
  • 20

1 Answers1

2

Download the file in binary mode (default for download.file is ASCII mode) with the mode argument set to wb:

download.file(myurl, mydestfile, mode="wb")
Dom
  • 1,043
  • 2
  • 10
  • 20