Skip to content
Prev 384771 / 398502 Next

read.csv fails in R console in Ubuntu terminal but works in RStudio after R 3.6.3 upgrade to R 4.0.2?

Hello,

R 4.0.2 on Ubuntu 20.04 LTS, sessionInfo below.

I'm also unable to read the file with Rscript from the Ubuntu terminal 
but the error is not the same as the OP's.


The first try was a file test1.R with the following commands.

x<-"https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download"
read.csv(x, as.is=TRUE, na="n/a")


And run with Rscript

rui at rui:~$ Rscript --vanilla test1.R
Error in file(file, "rt") :
   cannot open the connection to 
'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download'
Calls: read.csv -> read.table -> file
In addition: Warning message:
In file(file, "rt") :
   cannot open URL 
'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download': 
HTTP status was '403 Forbidden'
Execution halted



The second try was download.file() and then read it.
File test2.R is:

x<-"https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download"
download.file(x, "companylist.csv")
read.csv("companylist.csv", as.is=TRUE, na="n/a")


But this too failed with error 403 Forbiden.

rui at rui:~$ Rscript --vanilla test2.R
trying URL 
'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download'
Error in download.file(x, "companylist.csv") :
   cannot open URL 
'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download'
In addition: Warning message:
In download.file(x, "companylist.csv") :
   cannot open URL 
'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=1&render=download': 
HTTP status was '403 Forbidden'
Execution halted


This is my session info.

rui at rui:~$ Rscript --vanilla -e 'sessionInfo()'
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
  [1] LC_CTYPE=pt_PT.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=pt_PT.UTF-8        LC_COLLATE=pt_PT.UTF-8
  [5] LC_MONETARY=pt_PT.UTF-8    LC_MESSAGES=pt_PT.UTF-8
  [7] LC_PAPER=pt_PT.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.0.2



?s 08:45 de 15/07/20, Sam H escreveu: