Se integran al diccionario DIC_QUESTIONS la mayorías de los archivos del input

This commit is contained in:
Mongar28
2025-11-11 16:16:47 -05:00
parent d1573682c1
commit 17ac026d34
3 changed files with 26 additions and 45 deletions

View File

@@ -1 +1 @@
,forgedk,forgedk-VirtualBox,11.11.2025 13:58,file:///home/forgedk/.config/libreoffice/4; ,mongar,mongar,11.11.2025 15:24,file:///home/mongar/.config/libreoffice/4;

View File

@@ -1,49 +1,40 @@
#!/usr/bin/env python
# coding: utf-8
# # Imports
# In[29]:
import pandas as pd import pandas as pd
import os import os
import sys import sys
from extraccion import agentes_entidades
module_path = os.path.abspath(os.path.join(".."))
# In[30]:
module_path = os.path.abspath(os.path.join('..'))
# Add to sys.path if not already present # Add to sys.path if not already present
if module_path not in sys.path: if module_path not in sys.path:
sys.path.append(module_path) sys.path.append(module_path)
print(module_path) print(module_path)
from extraccion import agentes_entidades
# # Variables
# In[31]:
INPUT_FOLDER = f"{module_path}/input/Preguntas Categoricas/" INPUT_FOLDER = f"{module_path}/input/Preguntas Categoricas/"
OUTPUT_FOLDER = f"{module_path}/output/fase1" OUTPUT_FOLDER = f"{module_path}/output/fase1"
FILES_TO_PROCESS = os.listdir(INPUT_FOLDER) FILES_TO_PROCESS = os.listdir(INPUT_FOLDER)
DELIMITER = "|^" DELIMITER = "|^"
DIC_QUESTIONS = { DIC_QUESTIONS = {
"Encuesta_MediaG01Q02.csv":agentes_entidades.extractor_pre_1 "Encuesta_MediaG01Q02.csv": agentes_entidades.extractor_pre_1,
"Encuesta_MediaG01Q04.csv": agentes_entidades.extractor_pre_2,
"Encuesta_MediaG01Q10.csv": agentes_entidades.extractor_pre_3,
"Encuesta_MediaG03Q17.csv": agentes_entidades.extractor_pre_4,
"Encuesta_MediaG03Q18.csv": agentes_entidades.extractor_pre_5,
# "Encuesta_MediaG03Q19.csv": agentes_entidades.extractor_pre_6,
"Encuesta_MediaG04Q22.csv": agentes_entidades.extractor_pre_7,
"Encuesta_MediaG04Q23.csv": agentes_entidades.extractor_pre_8,
"Encuesta_MediaG04Q25.csv": agentes_entidades.extractor_pre_9,
"Encuesta_MediaG05Q30.csv": agentes_entidades.extractor_pre_10,
"Encuesta_MediaG05Q34.csv": agentes_entidades.extractor_pre_11,
# "Encuesta_MediaG05Q27.csv": agentes_entidades.extractor_pre_12,
"Encuesta_MediaG06Q35.csv": agentes_entidades.extractor_pre_13,
# "Encuesta_MediaG06Q37.csv": agentes_entidades.extractor_pre_14,
# "Encuesta_MediaG06Q39.csv": agentes_entidades.extractor_pre_15
# COMPLETAR RESTO # COMPLETAR RESTO
} }
# # Functions
# In[32]:
def extract_answers(answers): def extract_answers(answers):
answer_formated = "" answer_formated = ""
iterator_answers = answers.acciones iterator_answers = answers.acciones
@@ -52,18 +43,12 @@ def extract_answers(answers):
return answer_formated return answer_formated
# In[33]:
def format_answer(dataframe, function): def format_answer(dataframe, function):
dataframe["respuestas_formato"] = None dataframe["respuestas_formato"] = None
for index, row in dataframe.iterrows(): for index, row in dataframe.iterrows():
answers = function (row['respuesta']) answers = function(row["respuesta"])
answer_to_insert = extract_answers(answers) answer_to_insert = extract_answers(answers)
dataframe.loc[index,'respuestas_formato'] = answer_to_insert dataframe.loc[index, "respuestas_formato"] = answer_to_insert
# In[34]:
def format_all_answers(Dic_questions): def format_all_answers(Dic_questions):
@@ -73,8 +58,4 @@ def format_all_answers(Dic_questions):
question_dataframe.to_csv(OUTPUT_FOLDER + "/" + key) question_dataframe.to_csv(OUTPUT_FOLDER + "/" + key)
# In[35]:
format_all_answers(DIC_QUESTIONS) format_all_answers(DIC_QUESTIONS)

Binary file not shown.