Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPPIR-Tables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMPPIR
SMPPIR-Tables
Merge requests
!9
Add script to new table
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add script to new table
homicidios_jovens
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Edu Trevisan
requested to merge
homicidios_jovens
into
master
5 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
86a09b56
1 commit,
5 years ago
1 file
+
85
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Scripts/homicidios_jovens.py
0 → 100644
+
85
−
0
Options
# Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
# This file is part of SMPPIR-Tables.
# SMPPIR-Tables is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# SMPPIR-Tables is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with SMPPIR-Tables. If not, see <https://www.gnu.org/licenses/>.
# Para conseguir os dados dos homicídios de jovens siga os seguintes passos:
# 1 - Acesse o tabnet em estatísticas vitais nos dados de mortalidade geral em:
# http: // tabnet.datasus.gov.br/cgi/deftohtm.exe?sim/cnv/obt10uf.def
# 2 - Selecione os seguintes filtros:
# No filtro de linha selecione "Unidade de Federação"
# Na coluna selecione "Cor/Raça"
# No conteúdo selecione "Óbitos p/Ocorrência"
# Selecione o ano desejado
# Na Causa - CID-BR-10 selecione ".110 Agressões"
# Na Faixa Etária selecione o intervalo de 15 a 29 anos(use Ctrl para selecionar os 2)
# 3 - Selecione Colunas separadas por ";" e clique em "Mostra"
# 4 - Copie o resultado descartando o "&" no folder dados em um arquivo chamado
# homicidios_jovens_201X.csv
# 5 - Execute o script homicidios_jovens.py
# 6 - O resultado está no folder dadosProcessados
import
os
import
csv
import
sys
folder
=
"
dados/
"
fileName
=
"
homicidios_jovens_
"
year
=
int
(
input
(
"
Ano:
"
))
# Tentar abrir arquivo
try
:
ifile
=
open
(
folder
+
fileName
+
str
(
year
)
+
'
.csv
'
,
'
r
'
)
except
IOError
:
print
(
'
Arquivo nao encontrado:
'
+
folder
+
fileName
+
str
(
year
)
+
'
.csv
'
)
exit
()
if
not
os
.
path
.
exists
(
'
dadosProcessados
'
):
os
.
makedirs
(
'
dadosProcessados
'
)
# Se nao houve erro tratar csv
reader
=
csv
.
reader
(
ifile
,
delimiter
=
'
;
'
)
ofile
=
open
(
'
dadosProcessados/
'
+
fileName
+
str
(
year
)
+
'
.csv
'
,
'
w
'
)
writer
=
csv
.
writer
(
ofile
,
delimiter
=
'
|
'
)
# Escrever header no arquivo
headers
=
next
(
reader
,
None
)
headers
.
insert
(
0
,
'
estado_id
'
)
headers
.
append
(
'
ANO_CENSO
'
)
writer
.
writerow
(
headers
)
# Escrever linhas no arquivo com informacoes do ano
for
row
in
reader
:
row
.
insert
(
0
,
row
[
0
].
split
()[
0
])
for
i
,
string
in
enumerate
(
row
):
row
[
i
]
=
string
.
replace
(
"
-
"
,
"
0
"
)
row
.
append
(
year
)
if
row
[
0
]
!=
'
Total
'
:
writer
.
writerow
(
row
)
ifile
.
close
()
ofile
.
close
()
Loading