Last active
June 25, 2023 16:03
-
-
Save fernandobarbalho/359b7f04270e402d58dcf9cae18c5cde to your computer and use it in GitHub Desktop.
Script para download de base de dados de bolsa família
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Faça download de um conjunto de tabelas do bolsa família referente a qualquer período a partir de janeiro de 2003 | |
base_address<- "http://transparencia.gov.br/download-de-dados/bolsa-familia-pagamentos/" | |
#Alterar as variáveis abaixo de acordo com o que se deseja | |
ano_ini<- 2018 | |
ano_fim<- 2018 | |
mes_ini<-1 | |
ult_mes_disp<- 2 | |
for (ano in ano_ini:2018){ | |
if (ano == ano_fim) {mes_fim<-ult_mes_disp} | |
for (mes in mes_ini:mes_fim){ | |
mes<- ifelse(mes>=10,as.character(mes),paste0('0',mes)) | |
arq_down<- paste0(base_address,ano,mes) | |
download.file(arq_down,destfile = paste0(ano,mes,'_BF','.zip'), mode='wb') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment