Skip to content

fread only allows URLs on input, not file #4952

@pnacht

Description

@pnacht

The documentation for fread's argument file states

[...] a URL starting http:// [...]

However, if I try reading a file via HTTP, I can only get it to work by passing it to the generic input, not file.

library(data.table)
packageVersion("data.table")
#> [1] ‘1.14.0’

x <- "http://dados.cvm.gov.br/dados/FI/DOC/INF_DIARIO/DADOS/inf_diario_fi_202012.csv"

fread(x, sep = ";")
#>         TP_FUNDO         CNPJ_FUNDO  DT_COMPTC VL_TOTAL  VL_QUOTA VL_PATRIM_LIQ
#>      1:       FI 00.017.024/0001-53 2020-12-01  1099408 27.493767       1098370
#>      2:       FI 00.017.024/0001-53 2020-12-02  1099497 27.493801       1098371
#>      [...]

fread(file = x, sep = ";")
#> Error in fread(file = x, sep = ";"): File 'http://dados.cvm.gov.br/dados/FI/DOC/INF_DIARIO/DADOS/inf_diario_fi_202012.csv' does not exist or is non-readable. getwd()=='[...]'

Created on 2021-04-12 by the reprex package (v1.0.0)

# Output of sessionInfo()

sessionInfo()
#> R version 4.0.5 (2021-03-31)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19041)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] fansi_0.4.2       crayon_1.4.1      utf8_1.2.1        digest_0.6.27    
#>  [5] backports_1.2.1   lifecycle_1.0.0   reprex_1.0.0      magrittr_2.0.1   
#>  [9] evaluate_0.14     pillar_1.5.1      highr_0.8         stringi_1.5.3    
#> [13] rlang_0.4.10      fs_1.5.0          vctrs_0.3.7       ellipsis_0.3.1   
#> [17] rmarkdown_2.7     styler_1.3.2      tools_4.0.5       stringr_1.4.0    
#> [21] glue_1.4.2        purrr_0.3.4       xfun_0.22         yaml_2.2.1       
#> [25] compiler_4.0.5    pkgconfig_2.0.3   htmltools_0.5.1.1 knitr_1.31       
#> [29] tibble_3.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions