I am trying to download and extract a .csv file from a webpage using R.
This question is a duplicate of Using R to download zipped data file, extrac
It's almost everything ok. In this case you only need to specify that it's a comma separated file, eg using sep=","
in read.table
:
temp <- tempfile()
download.file("http://api.worldbank.org/v2/en/country/gbr?downloadformat=csv",
temp)
con <- unz(temp, "gbr_Country_en_csv_v2.csv")
dat <- read.table(con, header=T, skip=2, sep=",")
unlink(temp)
With this little change i can import your csv smoothly.
HTH, Luca