pssguy
pssguy

Reputation: 3515

Automating downloading of csv using R

The UK Charity Commission has a site from which you can download charity data for a specified category e.g. dementia http://beta.charitycommission.gov.uk/charity-search/?q=dementia enter image description here

When hovering over the Export Button, the link URL is shown at the bottom with the search item and number of charities included

The actual file downloaded is named "charitydetails_2017_06_14_23_57_17.csv" so no mention of category/number but with a date-stamp instead

I have tried

library(readr)
df <- read_csv("http://beta.charitycommission.gov.uk/charity-search/?q=dementia&exportCSV=317.csv")

but just get 404 error

Is there anyways in R that I can automate this so that entering a different term e.g. blind in, say, a shiny app would download the correct dataset into R for processing?

TIA

Upvotes: 0

Views: 89

Answers (1)

neilfws
neilfws

Reputation: 33802

You used an incorrect URL. The correct one is:

http://beta.charitycommission.gov.uk/charity-search/?q=dementia&exportCSV=1&p=317

Upvotes: 1

Related Questions