Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to download who16? #208

Open
hans-ekbrand opened this issue Mar 4, 2021 · 1 comment
Open

Fails to download who16? #208

hans-ekbrand opened this issue Mar 4, 2021 · 1 comment

Comments

@hans-ekbrand
Copy link

download_all_icd_data()
Not all available data is currently downloaded. You may use: ‘download_all_icd_data()’ to complete downloading all available data, or let this happen on demand.
Using ‘[my homedir]cache/R/icd’ for saving ICD data.
Downloading, caching and parsing all ICD data
This will take a few minutes, and use about 340MB.
Working on: icd9cm2014_leaf
Working on: icd10cm2019
Working on: icd10who2016
Error : Argument 'txt' must be a JSON string, URL or file.
Working on: icd10who2008fr
Error : Argument 'txt' must be a JSON string, URL or file.
Working on: icd10fr2019
Error in utils::unzip(zipfile, exdir = zipdir) : 
  (converted from warning) error 1 in extracting from zip file
Working on: icd10be2014
Downloading icd10be2014 data
Working on: icd10be2014_pc
Working on: icd10be2017
Downloading icd10be2017 data
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to www.health.belgium.be:443 
Error in utils::download.file(url = url, destfile = save_path, quiet = TRUE,  : 
  'curl' call had nonzero exit status
Working on: icd10be2017_pc
Working on: icd9cm2005_leaf
[more successful ones]...

Seems like a few URL:s aren't working.

@hans-ekbrand hans-ekbrand changed the title Failes to download who16? Fails to download who16? Mar 4, 2021
@nathandalton
Copy link

Hi Hans,

I have also had this issue, but believe I have found the cause for some of the errors thrown.

Given the icd package is currently not available on the CRAN respository, I downloaded the most recent version of icd (4.0.9) available from the CRAN archive and installed from source. When running download_all_icd_data(), I encountered the same errors as yourself.

Upon debugging, it appears the error in accessing WHO 2016 is due to a line in the who.R file (which Jack has already fixed here: 450126c)

json_data <- httr::content(http_response, simplifyDataFrame=TRUE)

To the best of my understanding, json_data was not a valid JSON object for manipulation in the next call, resulting in the error 'Error : Argument 'txt' must be a JSON string, URL or file.'.

The following code which Jack has written, however, does provide a fix:

  # encoding not specified by WHO resource (as of 2020-06-06).  Be explicit
  # about assumption.
  json_data <- httr::content(http_response, type = "text", encoding = "UTF-8")

The method I used to edit is as follows:

  1. Call options(error=recover). This call assists with stepping through the function causing the problem.
  2. Call get_icd10who2016().
  3. Select option 9 (i.e. .dl_icd10who_json(year, lang, resource)).
  4. Call trace(.dl_icd10who_json, edit = TRUE).
  5. In the popup, find the error line from above and replace it with json_data <- httr::content(http_response, type = "text", encoding = "UTF-8") and save.
  6. Press Esc.
  7. Exit recover mode by calling options(error=NULL).

It appears that this has fixed my problem.

For anyone reading this -- if this method of amending a package that I have used above is not the best way to do so, I would appreciate if you could tell me a better way! I'm relatively new to R, and working with packages is very new to me.

Kind regards,
N

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants