Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dados_rastreador
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Camex Público
dados_rastreador
Commits
f54fac98
Commit
f54fac98
authored
Nov 10, 2025
by
Miguel Guerrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrige descrições
parent
5b29f7cd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
66 deletions
+93
-66
dados_gerados/descricoes_ncm.parquet
dados_gerados/descricoes_ncm.parquet
+0
-0
scripts/gera_correlacoes.R
scripts/gera_correlacoes.R
+93
-66
No files found.
dados_gerados/descricoes_ncm.parquet
View file @
f54fac98
No preview for this file type
scripts/gera_correlacoes.R
View file @
f54fac98
...
...
@@ -59,7 +59,7 @@ path_descricoes <- file.path(
Sys.getenv
(
"general"
),
"Bases"
,
"NCM_sh1996_a_sh2022"
,
"
NCMs
_sh.xlsx"
"
descricoes_ncm
_sh.xlsx"
)
...
...
@@ -172,61 +172,88 @@ write_parquet(correlacao_completa, "dados_gerados/dataset_naladi.parquet")
# Processa e organiza descrições NCM --------------------------------------
descricoes_por_sh
<-
read_excel
(
path_descricoes
,
guess_max
=
1e5
)
%>%
rename
(
sh
=
grupo_sh
)
# obtem abas disponíveis
abas
<-
readxl
::
excel_sheets
(
path_descricoes
)
# obtem nome da ultima aba
ultimo_sh
<-
abas
[
length
(
abas
)]
# remove ultima aba
abas
<-
abas
[
-
length
(
abas
)]
ultimo_sh
<-
descricoes_por_sh
%>%
distinct
(
sh
)
%>%
pull
(
sh
)
%>%
max
()
append_descricoes
<-
function
(
aba
)
{
read_xlsx
(
path_descricoes
,
sheet
=
aba
)
%>%
descricoes_por_sh
<-
descricoes_por_sh
%>%
# remove o ultimo sh, pois ha ncms que ja deixaram de existir
filter
(
sh
!=
ultimo_sh
)
%>%
mutate
(
across
(
everything
(),
~
if_else
(
is.na
(
.x
),
""
,
.x
)
),
across
(
everything
(),
~
str_replace
(
.x
,
"^- "
,
"-"
)
),
across
(
everything
(),
~
str_replace
(
.x
,
"^-- "
,
"--"
)
ncm
=
paste0
(
str_sub
(
ncm
,
1
,
4
),
"."
,
str_sub
(
ncm
,
5
,
6
),
"."
,
str_sub
(
ncm
,
7
,
8
)
),
)
%>%
transmute
(
codigoFormatado
,
sh
,
descricao
=
paste
(
desc_pos
,
desc_subpos5
,
desc_subpos6
,
desc_item
,
desc_subitem
,
sep
=
"\n"
)
)
%>%
mutate
(
descricao
=
str_replace_all
(
descricao
,
"\n\n\n\n\n|\n\n\n\n|\n\n\n|\n\n"
,
"\n"
)
)
%>%
mutate
(
descricao
=
str_remove
(
descricao
,
"\n$"
)
sh
=
paste
(
"NCM"
,
sh
)
)
}
descricoes_por_sh
<-
purrr
::
map_dfr
(
abas
,
~
append_descricoes
(
.x
)
)
%>%
rename
(
ncm
=
codigoFormatado
)
%>%
mutate
(
sh
=
str_replace
(
sh
,
"SH"
,
"NCM"
))
####################
# # obtem abas disponíveis
# abas <- readxl::excel_sheets(path_descricoes)
# # obtem nome da ultima aba
# ultimo_sh <- abas[length(abas)]
# # remove ultima aba
# abas <- abas[-length(abas)]
# append_descricoes <- function(aba) {
# read_xlsx(path_descricoes, sheet = aba) %>%
# mutate(
# across(
# everything(),
# ~if_else(is.na(.x), "", .x)
# ),
# across(
# everything(),
# ~str_replace(.x, "^- ", "-")
# ),
# across(
# everything(),
# ~str_replace(.x, "^-- ", "--")
# ),
# ) %>%
# transmute(
# codigoFormatado,
# sh,
# descricao = paste(
# desc_pos,
# desc_subpos5,
# desc_subpos6,
# desc_item,
# desc_subitem,
# sep = "\n"
# )
# ) %>%
# mutate(
# descricao = str_replace_all(
# descricao,
# "\n\n\n\n\n|\n\n\n\n|\n\n\n|\n\n",
# "\n"
# )
# ) %>%
# mutate(
# descricao = str_remove(descricao, "\n$")
# )
# }
# descricoes_por_sh <- purrr::map_dfr(
# abas,
# ~ append_descricoes(.x)
# ) %>%
# rename(ncm = codigoFormatado) %>%
# mutate(sh = str_replace(sh, "SH", "NCM"))
descricoes_atuais
<-
...
...
@@ -277,18 +304,18 @@ descricoes_por_sh <- descricoes_por_sh %>%
)
)
#####################################################
# ATENÇÃO: Solução provisória para descrições NCM ##
# Quando houver descrições para todas as NCMs ######
# remover o código abaixo ##########################
####################################################
descricoes_por_sh
<-
descricoes_por_sh
%>%
mutate
(
descricao
=
if_else
(
sh
!=
"NCM 2022"
,
" "
,
descricao
))
#
#
####################################################
#
#
ATENÇÃO: Solução provisória para descrições NCM ##
#
#
Quando houver descrições para todas as NCMs ######
#
#
remover o código abaixo ##########################
#
#
###################################################
#
#
descricoes_por_sh <- descricoes_por_sh %>%
#
mutate(descricao = if_else(
#
sh != "NCM 2022",
#
" ",
#
descricao
#
))
descricoes_por_sh
%>%
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment