Skip to content
Snippets Groups Projects
Commit aad22b2b authored by Jomaro Rodrigues's avatar Jomaro Rodrigues
Browse files

os dois problemas básicos de formato agora são tratados pelo sistema

parent ce287e94
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,8 @@ def crypt(name):
data = pd.read_csv('.'+name)
data.dropna(how='all', inplace=True)
if os.path.exists(TABLE_FILE):
table = pd.read_csv(TABLE_FILE)
else:
......@@ -80,7 +82,7 @@ def crypt(name):
if not os.path.exists(dirname):
os.makedirs(dirname)
table = pd.DataFrame(columns=["ID", "MATR_ALUNO", "NOME_PESSOA"])
table = pd.DataFrame(columns=["ID", "MATR_ALUNO", "NOME_ALUNO"])
table.to_csv(TABLE_FILE, index=False)
......@@ -93,22 +95,24 @@ def crypt(name):
#
# se o novo relatório inclui o nome dos alunos vamos colocar isso
# no arquivo de correspondencia tambem
# no arquivo de correspondencia tambem, e tira-lo do arquivo original
#
if "NOME_ALUNO" in data.columns:
data.rename(columns={'NOME_ALUNO': 'NOME_PESSOA'}, inplace=True)
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")
table_append["NOME_PESSOA"] = table_append.NOME_PESSOA.apply(UTF8toupper)
else:
table_append["NOME_PESSOA"] = ""
for field in ["NOME_ALUNO", "NOME_PESSOA"]:
if field in data.columns:
df = data[["MATR_ALUNO", field]].rename(columns={field: "NOME_ALUNO"})
table_append = pd.merge(table_append, df, how="left", on="MATR_ALUNO")
UTF8toupper = lambda s: s.decode("utf8").upper().encode("utf8")
table_append["NOME_ALUNO"] = table_append.NOME_ALUNO.apply(UTF8toupper)
del data[field]
if "NOME_ALUNO" not in table_append.columns:
table_append["NOME_ALUNO"] = ""
# pega todos os registros que ainda não existem no table
......@@ -143,9 +147,6 @@ def crypt(name):
del data["MATR_ALUNO"]
if "NOME_PESSOA" in data.columns:
del data["NOME_PESSOA"]
data.rename(columns={"ID": "MATR_ALUNO"}, inplace=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment