-2

I am trying to download a .xlsx file using the RCurl library and GetUrl() function.

But i get the error embedded nul in string: 'PK\003\004\024\0\006\0\b\0\0\0!\0ª÷X¤z\001\0\0\024\006\0\0\023\0\b\002[Content_Types].xml ¢\004\002( \0\002\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\'

Is there anyway to handle this? The same call works perfectly fine for .csv file formats.

Any Help is appreciated.

Thanks!

  • 1
    Could you post the code used? – Paulo MiraMor Jan 28 '17 at 01:32
  • 1
    `download.file` with `method = 'curl'` is usually sufficient. Or some Excel-reading functions can handle the connection directly, e.g. `openxlsx::read.xlsx('https://archive.ics.uci.edu/ml/machine-learning-databases/00242/ENB2012_data.xlsx')` – alistaire Jan 28 '17 at 01:37
  • or, y'know, you cld `readxl::read_excel("EXCEL_URL")` and be done with it – hrbrmstr Jan 28 '17 at 02:59

1 Answers1

1

You need to specify that this is a binary file, see documentation: https://www.rdocumentation.org/packages/RCurl/versions/1.95-4.8/topics/getURL

The reason is that xslx is a binary format, while csv is just text.

Lucero
  • 59,176
  • 9
  • 122
  • 152