Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 18654
Kernel: Python 3

From GSheet update Hugo project and chapters leaders

The original mapping was done on GSheets so let's use that data

(DON'T RUN THIS AGAIN, since after it's execution, Hugo is now the Single Source of Truth for the project's and chapter's data)

from oss_hugo.OSS_GSheet_Data import OSS_GSheet_Data from oss_hugo.API_Hugo_OSS import API_Hugo_OSS #from oss_hugo.OSS_Participant import OSS_Participant
gsheet = OSS_GSheet_Data() hugo = API_Hugo_OSS() participants = hugo.participants_oss() df_gsheet = gsheet.df_participants_onsite(['Name','Chapter Leader','Project Leader']) # Updating the Chapter Leaders values df_chapters = df_gsheet[df_gsheet['Chapter Leader'] != ''] for index, row in df_chapters.iterrows(): participant = participants.get(row['Name']) participant.set_field('chapter_leader', row['Chapter Leader']) participant.save() # Updating the Project Leaders values df_projects = df_gsheet[df_gsheet['Project Leader'] != ''] for index, row in df_projects.iterrows(): name = row['Name'] value = [x.strip() for x in row['Project Leader'].split(',')] participant = participants.get(name) participant.set_field('project_leader', value) participant.save() "all done"
# Updating the 'Skills/Topics' values df_gsheet = gsheet.df_participants_onsite(['Name','Skills/Topics']) df_skills = df_gsheet[df_gsheet['Skills/Topics'] != ''] for index, row in df_skills.iterrows(): name = row['Name'] value = [x.strip() for x in row['Skills/Topics'].split(',')] participant = participants.get(name) participant.set_field('interested_in', value) participant.save()

Looking at the data in Hugo

import numpy as np df = hugo.df_participants(['title','chapter_leader','project_leader']) df['project_leader'].replace('', np.nan, inplace=True) df['chapter_leader'].replace('', np.nan, inplace=True) df.dropna(thresh=2).fillna('').reset_index(drop=True)
hugo.df_participants(['title','interested_in']).dropna() field = 'chapter_leader'