def Orgs_tags(self): if len(self.orgs_table) == 0: print("No se encontraron registros nuevos de organizaciones") else: tabla = self.orgs_table column_list = clean.column_list(self.orgs_table) tabla = tabla[column_list + ["id"]] tabla = pd.concat([pd.DataFrame({"tags":tabla['tags']}),pd.DataFrame({"id":tabla['id']})], axis = 1) final_table = pd.DataFrame() for index, row in tabla.iterrows(): if len(row['tags']) == 0: pass else: id = row['id'] tags = row['tags'] inter_table = pd.DataFrame(tags, columns= ['tags']) inter_table['id'] = [id for i in range(len(inter_table)) ] final_table = final_table.append(inter_table) try: final_table.reset_index(inplace= True,drop= True ) except: pass if len(final_table) == 0: self.orgs_tags = final_table else: if self.tipo == "complete": # Borra la tabla anterior e inicializa una nueva con solo un ID, posteriormente comprueba las nuevas columnas # para insertarlas. Initialize("orgs_tags", self.engine) New_columns(final_table, "orgs_tags", self.engine) Upload_Redshift(final_table,"orgs_tags", "zendesk_support","zendesk-runahr",self.engine) if self.tipo == "partial": New_columns(final_table, "orgs_tags", self.engine) Upload_Redshift(final_table,"orgs_tags", "zendesk_support","zendesk-runahr",self.engine) self.orgs_tags =final_table
def Tickets(self): tabla = self.tickets_table column_list = clean.column_list(self.tickets_table) tabla = tabla.drop([str(i) for i in column_list], axis = 1) if self.tipo == "complete": # Borra la tabla anterior e inicializa una nueva con solo un ID, posteriormente comprueba las nuevas columnas # para insertarlas. Initialize("tickets", self.engine) New_columns(tabla, "tickets", self.engine) Upload_Redshift(tabla,"tickets", "zendesk_support","zendesk-runahr",self.engine) if self.tipo == "partial": New_columns(tabla, "tickets", self.engine) Upload_Redshift(tabla,"tickets", "zendesk_support","zendesk-runahr",self.engine)
def Orgs(self): if len(self.orgs_table) == 0: print("No se encontraron registros nuevos de organizaciones") else: tabla = self.orgs_table column_list = clean.column_list(self.orgs_table) tabla = tabla.drop([str(i) for i in column_list], axis = 1) if self.tipo == "complete": # Borra la tabla anterior e inicializa una nueva con solo un ID, posteriormente comprueba las nuevas columnas # para insertarlas. Initialize("orgs", self.engine) New_columns(tabla, "orgs", self.engine) Upload_Redshift(tabla,"orgs", "zendesk_support","zendesk-runahr",self.engine) if self.tipo == "partial": New_columns(tabla, "orgs", self.engine) Upload_Redshift(tabla,"orgs", "zendesk_support","zendesk-runahr",self.engine)
def Tickets_tags(self): final_table = pd.DataFrame() column_list = clean.column_list(self.tickets_table) tabla = self.tickets_table[column_list + ["id"]] tabla = pd.concat([pd.DataFrame({"tags":tabla['tags']}),pd.DataFrame({"id":tabla['id']})], axis = 1) for index, row in tabla.iterrows(): id = row['id'] tags = row['tags'] inter_table = pd.DataFrame(tags, columns= ['tags']) inter_table['id'] = [id for i in range(len(inter_table)) ] final_table = final_table.append(inter_table) if int(index) % 1000 == 0: print("tags del ticket: " + str(index)) final_table.reset_index(inplace= True,drop= True ) if self.tipo == "complete": # Borra la tabla anterior e inicializa una nueva con solo un ID, posteriormente comprueba las nuevas columnas # para insertarlas. Initialize("tickets_tags", self.engine) New_columns(final_table, "tickets_tags", self.engine) Upload_Redshift(final_table,"tickets_tags", "zendesk_support","zendesk-runahr",self.engine) if self.tipo == "partial": New_columns(final_table, "tickets_tags", self.engine) Upload_Redshift(final_table,"tickets_tags", "zendesk_support","zendesk-runahr",self.engine)