Skip to content

Commit

Permalink
retorna colunas originais
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Jan 10, 2025
1 parent 261ecd6 commit a72a8f2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
8 changes: 5 additions & 3 deletions R/geocode.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ geocode <- function(addresses_table,

# create temp id
input_padrao[, tempidgeocodebr := 1:nrow(input_padrao) ]
data.table::setDT(addresses_table)[, tempidgeocodebr := 1:nrow(input_padrao) ]


# downloading cnefe. we only need to download the states present in the
# addresses table, which may save us some time.
Expand Down Expand Up @@ -194,14 +196,14 @@ geocode <- function(addresses_table,
add_precision_col(con, update_tb = 'output_db')

# output with all original columns
duckdb::dbWriteTable(con, "input_padrao_db", input_padrao,
duckdb::dbWriteTable(con, "input_db", addresses_table,
temporary = TRUE, overwrite=TRUE)

x_columns <- names(input_padrao)
x_columns <- names(addresses_table)

output_deterministic <- merge_results(
con,
x='input_padrao_db',
x='input_db',
y='output_db',
key_column='tempidgeocodebr',
select_columns = x_columns
Expand Down
58 changes: 29 additions & 29 deletions inst/extdata/small_sample.csv
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
id;nm_logradouro;Numero;Cep;Bairro;nm_municipio;code_muni;nm_uf
1;RUA MARIA LUCIA PACIFICO;17;26042-730;SANTA RITA;NOVA IGUACU;3303500;RIO DE JANEIRO
2;RUA LEOPOLDINA TOME;46;25030-050;CENTENARIO;DUQUE DE CAXIAS;3301702;RIO DE JANEIRO
3;RUA DONA JUDITE;0;23915-700;CAPUTERA II;ANGRA DOS REIS;3300100;RIO DE JANEIRO
4;RUA ALEXANDRE AMARAL;0;23098-120;SANTISSIMO;RIO DE JANEIRO;3304557;RIO DE JANEIRO
5;AVENIDA E;300;23860-000;PRAIA GRANDE;MANGARATIBA;3302601;RIO DE JANEIRO
6;RUA PRINCESA ISABEL;263;69921-026;ESTACAO EXPERIMENTAL;RIO BRANCO;1200401;ACRE
7;CAMINHO SEM DENOMINACAO;2530;69980-000;MIRITIZAL;CRUZEIRO DO SUL;1200203;ACRE
8;RUA DO LIMAO;268;69920-048;MOCINHA MAGALHAES;RIO BRANCO;1200401;ACRE
9;RUA GERALDO MESQUITA;0;69918-202;NOVA ESTACAO;RIO BRANCO;1200401;ACRE
10;AVENIDA CASTELO BRANCO;3875;69925-000;DEMOCRACIA;SENADOR GUIOMARD;1200450;ACRE
11;RUA LUCIO MARINHO CRUZ;91;57180-000;CENTRO;BARRA DE SAO MIGUEL;2501708;ALAGOAS
12;CONJUNTO GISLENE MATEUS;12;57160-000;TAPERAGUA;MARECHAL DEODORO;2704708;ALAGOAS
13;RUA MONTEIROPOLIS;6;57071-238;CLIMA BOM;MACEIO;2704302;ALAGOAS
14;RUA PRESIDENTE GETULIO VARGAS;1303;57580-000;CENTRO;MAJOR ISIDORO;2704401;ALAGOAS
15;RUA FRANCISCO DE HOLANDA;9;57073-735;CIDADE UNIVERSITARIA;MACEIO;2704302;ALAGOAS
16;RUA MARIA LUCIA PACIFICO;17;26042-730;;NOVA IGUACU;3303500;RIO DE JANEIRO
17;RUA PRINCESA ISABEL;263;;ESTACAO EXPERIMENTAL;RIO BRANCO;1200401;ACRE
18;RUA LUCIO MARINHO CRUZ;91;;;BARRA DE SAO MIGUEL;2501708;ALAGOAS
19;;;;;Rio Branco;1200401;ACRE
20;RUA RUI BARBOSA;108;;;Rio Branco;1200401;ACRE
21;RUA RUI BARBOSA;;;;Rio Branco;1200401;ACRE
22;;;;Copacabana;RIO DE JANEIRO;3304557;RIO DE JANEIRO
23;;;22280-005;Botafogo;RIO DE JANEIRO;3304557;RIO DE JANEIRO
24;;;22280-005;;RIO DE JANEIRO;3304557;RIO DE JANEIRO
25;RUA LEOPOLDINA TOME;;25030-050;CENTENARIO;DUQUE DE CAXIAS;3301702;RIO DE JANEIRO
26;RUA LEOPOLDINA TOME;46;25030-050;;DUQUE DE CAXIAS;3301702;RIO DE JANEIRO
27;CONJUNTO GISLENE MATEUS;;57160-000;;MARECHAL DEODORO;2704708;ALAGOAS
28;RUA MARIA LUCIA PACIFICO;;;SANTA RITA;NOVA IGUACU;3303500;RIO DE JANEIRO
id,nm_logradouro,Numero,Cep,Bairro,nm_municipio,code_muni,nm_uf
1,RUA MARIA LUCIA PACIFICO,17,26042-730,SANTA RITA,NOVA IGUACU,3303500,RIO DE JANEIRO
2,RUA LEOPOLDINA TOME,46,25030-050,CENTENARIO,DUQUE DE CAXIAS,3301702,RIO DE JANEIRO
3,RUA DONA JUDITE,0,23915-700,CAPUTERA II,ANGRA DOS REIS,3300100,RIO DE JANEIRO
4,RUA ALEXANDRE AMARAL,0,23098-120,SANTISSIMO,RIO DE JANEIRO,3304557,RIO DE JANEIRO
5,AVENIDA E,300,23860-000,PRAIA GRANDE,MANGARATIBA,3302601,RIO DE JANEIRO
6,RUA PRINCESA ISABEL,263,69921-026,ESTACAO EXPERIMENTAL,RIO BRANCO,1200401,ACRE
7,CAMINHO SEM DENOMINACAO,2530,69980-000,MIRITIZAL,CRUZEIRO DO SUL,1200203,ACRE
8,RUA DO LIMAO,268,69920-048,MOCINHA MAGALHAES,RIO BRANCO,1200401,ACRE
9,RUA GERALDO MESQUITA,0,69918-202,NOVA ESTACAO,RIO BRANCO,1200401,ACRE
10,AVENIDA CASTELO BRANCO,3875,69925-000,DEMOCRACIA,SENADOR GUIOMARD,1200450,ACRE
11,RUA LUCIO MARINHO CRUZ,91,57180-000,CENTRO,BARRA DE SAO MIGUEL,2501708,ALAGOAS
12,CONJUNTO GISLENE MATEUS,12,57160-000,TAPERAGUA,MARECHAL DEODORO,2704708,ALAGOAS
13,RUA MONTEIROPOLIS,6,57071-238,CLIMA BOM,MACEIO,2704302,ALAGOAS
14,RUA PRESIDENTE GETULIO VARGAS,1303,57580-000,CENTRO,MAJOR ISIDORO,2704401,ALAGOAS
15,RUA FRANCISCO DE HOLANDA,9,57073-735,CIDADE UNIVERSITARIA,MACEIO,2704302,ALAGOAS
16,RUA MARIA LUCIA PACIFICO,17,26042-730,"",NOVA IGUACU,3303500,RIO DE JANEIRO
17,RUA PRINCESA ISABEL,263,"",ESTACAO EXPERIMENTAL,RIO BRANCO,1200401,ACRE
18,RUA LUCIO MARINHO CRUZ,91,"","",BARRA DE SAO MIGUEL,2501708,ALAGOAS
19,"",,"","",Rio Branco,1200401,ACRE
20,RUA RUI BARBOSA,108,"","",Rio Branco,1200401,ACRE
21,RUA RUI BARBOSA,,"","",Rio Branco,1200401,ACRE
22,"",,"",Copacabana,RIO DE JANEIRO,3304557,RIO DE JANEIRO
23,"",,22280-005,Botafogo,RIO DE JANEIRO,3304557,RIO DE JANEIRO
24,"",,22280-005,"",RIO DE JANEIRO,3304557,RIO DE JANEIRO
25,RUA LEOPOLDINA TOME,,25030-050,CENTENARIO,DUQUE DE CAXIAS,3301702,RIO DE JANEIRO
26,RUA LEOPOLDINA TOME,46,25030-050,"",DUQUE DE CAXIAS,3301702,RIO DE JANEIRO
27,CONJUNTO GISLENE MATEUS,,57160-000,"",MARECHAL DEODORO,2704708,ALAGOAS
28,RUA MARIA LUCIA PACIFICO,,"",SANTA RITA,NOVA IGUACU,3303500,RIO DE JANEIRO

0 comments on commit a72a8f2

Please sign in to comment.