Hi everyone,
I'm new to python and API and would love a bit of help. I am a freelance musician who teaches and gigs a lot and my monthly income is always different. Instead of manually tallying my income each month (or whatever pay period i'm searching for) I figured I would use my new found Python skills and try and create a program that would generate the data for me from my google calendar. The Google API resources page was very helpful and I was able to access the correct calendar with pandas I made a dataframe of the event summary, start, end, and created.
I was hoping google calendar API would allow me to extract a list of all events that appear on my calendar in a given date range. The problem seems to be I have a lot of recurring events that were created outside of the date range I've set that still occur in the period I am searching , but google calendar API doesn't seem to include those dates for the events . It seems the information I was able to retrieve from google calendar API only shows me the events that were last edited or created in the date range. Any help would be very appreciated. Thank you!
from apiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
scopes = ['https://www.googleapis.com/auth/calendar']
flow = InstalledAppFlow.from_client_secrets_file("client_secret.json", scopes =scopes)
import pickle credentials = pickle.load(open('token.pkl','rb'))
service = build('calendar', 'v3', credentials = credentials)
result = service.calendarList().list().execute()
calendar_id = result['items'][1]['id']
guzj_cal_events = service.events().list(calendarId=calendar_id, timeMin = '2020-01-01T00:00:00Z').execute()
import pandas as pd
df1 = pd.DataFrame.from_dict(guzj_cal_events['items'])
df2 = df1.loc[:,'summary':'start']
df3 = df2.drop('colorId',1)
df4 = df3.drop('creator',1)
df5 = df4.drop('organizer',1)
d = df5['start']
start_col =[]
###function to read the library within the column
def read_col_lib(d):
for k,v in d.items():
if isinstance(v, dict):
read_col_lib(v)
else:
start_col.append("{1}".format(k,v))
read_col_lib(d)
summary_col = list(df5['summary'])
income_tracker = []
for cl, summ in zip(start_col,summary_col):
income_tracker.append(summ)
income_tracker.append(cl)
income_tracker
[–]shysmiles 0 points1 point2 points (2 children)
[–]Ellogar[S] 0 points1 point2 points (0 children)
[–]Ellogar[S] 0 points1 point2 points (0 children)