Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adega-crypt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Jomaro Rodrigues
adega-crypt
Commits
ce287e94
Commit
ce287e94
authored
9 years ago
by
Jomaro Rodrigues
Browse files
Options
Downloads
Patches
Plain Diff
metade da correção do problema das colunas
parent
40d4683a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
adega_crypt.py
+55
-7
55 additions, 7 deletions
adega_crypt.py
check.py
+3
-0
3 additions, 0 deletions
check.py
with
58 additions
and
7 deletions
adega_crypt.py
+
55
−
7
View file @
ce287e94
...
@@ -6,6 +6,8 @@ import sys
...
@@ -6,6 +6,8 @@ import sys
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
import
numpy
as
np
import
os
import
os
import
shutil
import
re
...
@@ -36,7 +38,39 @@ $ %s -d relatorio.csv
...
@@ -36,7 +38,39 @@ $ %s -d relatorio.csv
def
crypt
(
name
):
def
crypt
(
name
):
data
=
pd
.
read_csv
(
name
)
notify_empty_lines
=
False
notify_comma_decimal_separator
=
False
if
not
os
.
path
.
exists
(
'
.
'
+
name
):
shutil
.
copyfile
(
name
,
'
.
'
+
name
)
else
:
print
(
'
arquivo .%s ja existe, abortando
'
%
name
)
sys
.
exit
(
1
)
comma_separator
=
re
.
compile
(
ur
'
,33333333|,66666666
'
)
orig
=
open
(
name
,
'
r
'
)
rep
=
open
(
'
.
'
+
name
,
'
w+
'
)
for
line
in
orig
:
if
len
(
line
)
==
0
:
notify_empty_lines
=
True
elif
comma_separator
.
search
(
line
):
notify_comma_decimal_separator
=
True
#l = line.decode('utf8').replace(r',33333333', r'.33333333').replace(r',66666666', r'.66666666').encode('utf8')
l
=
line
.
replace
(
r
'
,33333333
'
,
r
'
.33333333
'
).
replace
(
r
'
,66666666
'
,
r
'
.66666666
'
)
rep
.
write
(
l
)
else
:
rep
.
write
(
line
)
orig
.
close
()
rep
.
close
()
#sys.exit(5)
data
=
pd
.
read_csv
(
'
.
'
+
name
)
if
os
.
path
.
exists
(
TABLE_FILE
):
if
os
.
path
.
exists
(
TABLE_FILE
):
table
=
pd
.
read_csv
(
TABLE_FILE
)
table
=
pd
.
read_csv
(
TABLE_FILE
)
...
@@ -46,7 +80,7 @@ def crypt(name):
...
@@ -46,7 +80,7 @@ def crypt(name):
if
not
os
.
path
.
exists
(
dirname
):
if
not
os
.
path
.
exists
(
dirname
):
os
.
makedirs
(
dirname
)
os
.
makedirs
(
dirname
)
table
=
pd
.
DataFrame
(
columns
=
[
"
ID
"
,
"
MATR_ALUNO
"
,
"
NOME_
ALUNO
"
])
table
=
pd
.
DataFrame
(
columns
=
[
"
ID
"
,
"
MATR_ALUNO
"
,
"
NOME_
PESSOA
"
])
table
.
to_csv
(
TABLE_FILE
,
index
=
False
)
table
.
to_csv
(
TABLE_FILE
,
index
=
False
)
...
@@ -63,15 +97,18 @@ def crypt(name):
...
@@ -63,15 +97,18 @@ def crypt(name):
#
#
if
"
NOME_ALUNO
"
in
data
.
columns
:
if
"
NOME_ALUNO
"
in
data
.
columns
:
data
.
rename
(
columns
=
{
'
NOME_ALUNO
'
:
'
NOME_PESSOA
'
},
inplace
=
True
)
table_append
=
pd
.
merge
(
table_append
,
data
[[
"
MATR_ALUNO
"
,
"
NOME_ALUNO
"
]],
how
=
"
left
"
,
on
=
"
MATR_ALUNO
"
)
if
"
NOME_PESSOA
"
in
data
.
columns
:
table_append
=
pd
.
merge
(
table_append
,
data
[[
"
MATR_ALUNO
"
,
"
NOME_PESSOA
"
]],
how
=
"
left
"
,
on
=
"
MATR_ALUNO
"
)
UTF8toupper
=
lambda
s
:
s
.
decode
(
"
utf8
"
).
upper
().
encode
(
"
utf8
"
)
UTF8toupper
=
lambda
s
:
s
.
decode
(
"
utf8
"
).
upper
().
encode
(
"
utf8
"
)
table_append
[
"
NOME_
ALUNO
"
]
=
table_append
.
NOME_
ALUNO
.
apply
(
UTF8toupper
)
table_append
[
"
NOME_
PESSOA
"
]
=
table_append
.
NOME_
PESSOA
.
apply
(
UTF8toupper
)
else
:
else
:
table_append
[
"
NOME_
ALUNO
"
]
=
""
table_append
[
"
NOME_
PESSOA
"
]
=
""
# pega todos os registros que ainda não existem no table
# pega todos os registros que ainda não existem no table
...
@@ -106,8 +143,8 @@ def crypt(name):
...
@@ -106,8 +143,8 @@ def crypt(name):
del
data
[
"
MATR_ALUNO
"
]
del
data
[
"
MATR_ALUNO
"
]
if
"
NOME_
ALUNO
"
in
data
.
columns
:
if
"
NOME_
PESSOA
"
in
data
.
columns
:
del
data
[
"
NOME_
ALUNO
"
]
del
data
[
"
NOME_
PESSOA
"
]
data
.
rename
(
columns
=
{
"
ID
"
:
"
MATR_ALUNO
"
},
inplace
=
True
)
data
.
rename
(
columns
=
{
"
ID
"
:
"
MATR_ALUNO
"
},
inplace
=
True
)
...
@@ -130,6 +167,17 @@ def crypt(name):
...
@@ -130,6 +167,17 @@ def crypt(name):
#
#
data
.
to_csv
(
"
.
"
.
join
(
split_name
),
index
=
False
)
data
.
to_csv
(
"
.
"
.
join
(
split_name
),
index
=
False
)
os
.
remove
(
'
.
'
+
name
)
if
notify_empty_lines
or
notify_comma_decimal_separator
:
print
"
Warnings:
"
if
notify_empty_lines
:
print
"
Linha em branco presente no arquivo
"
if
notify_comma_decimal_separator
:
print
"
virgula foi usada como separador de campo decimal
"
return
data
return
data
...
...
This diff is collapsed.
Click to expand it.
check.py
100644 → 100755
+
3
−
0
View file @
ce287e94
#!/usr/bin/env python
# coding: utf-8
import
pandas
as
pd
import
pandas
as
pd
import
os
import
os
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment