Read gzipped csv directly from a url in R

前端 未结 3 1341
终归单人心
终归单人心 2020-12-01 09:54

I\'m looking to download a gzipped csv and load it as an R object without saving it first to disk. I can do this with zipped files but can\'t seem to get it to work with

3条回答
  •  隐瞒了意图╮
    2020-12-01 10:07

    Using data.table::fread :

    x <- data.table::fread("http://dumps.wikimedia.org/other/articlefeedback/aa_combined-20110321.csv.gz")
    
    dim(x)
    [1] 1490   19
    
    x[, 1:2]
    #       aa_page_id page_namespace
    #    1:   26224556              0
    #    2:      31653              0
    #    3:   26224556              0
    #    4:   26224556              0
    #    5:    1058990              0
    #   ---                          
    # 1486:     619464              0
    # 1487:   19283361              0
    # 1488:   19006979              0
    # 1489:    5078775              0
    # 1490:   30209619              0
    

提交回复
热议问题