Reputation: 11954
Readr is great for loading data. It can handle URLs and compression. I am trying to use a source that has both. How can this be done. See the error below. The first attempt fails. But when I first download the file and then read it, it works. (second part of code). How do I tell readr to do both.
> d<-read_csv(fname)
> library(readr)
> prefix='ftp://ftp.ncbi.nlm.nih.gov/pub/medgen/csv/'
> fname='NAMES.csv.gz'
> d<-read_csv(paste0(prefix,fname))
Error in collectorsGuess(source, tokenizer, n = 100) :
embedded nul in string: 'ÝXÆ\0¯Uó\aÛ„Ë\023'
> download.file(paste0(prefix,fname), fname, mode="wb")
trying URL 'ftp://ftp.ncbi.nlm.nih.gov/pub/medgen/csv/NAMES.csv.gz'
downloaded 3.6 MB
> d<-read_csv(fname)
Upvotes: 3
Views: 1034
Reputation: 11954
version 0.2.2 of reader can handle both nicely. The error was with older version.
Upvotes: 1