Skip to main content

A Python library for analyzing Google Calendar data.

Project description

PyPi Package Version PyPi status PyPi downloads Supported Python versions

Google Calendar Analytics

img



This Python program allows you to perform analytics on your Google Calendar events. With this program, you can visualize the total duration of your events, compare the length of events across different time periods, and gain insights into which events take up the most time.

Features

  • Async support for faster data retrieval and chart generation
  • Extract events from your Google Calendar
  • Compute the total duration of events in a specified time range
  • Visualize the duration of events in a pie chart, bar chart, line chart and more
  • Limit the number of events displayed in the charts
  • Wide chart customization. For example, dark mode and transparent background

Quick Start

To use the Google Calendar Analytics program, first install the dependencies by running the following command:

pip install google-calendar-analytics

You can then import the AnalyzerFacade class and use it to analyze your data:

How to get credentials from Google?

  1. Google documentation
import asyncio
from datetime import datetime

from google.oauth2.credentials import Credentials
from google_calendar_analytics import AnalyzerFacade

# (You can get it from Google OAuth2 in you web app or from link above)
creds = {
    "token": "ya29.a0AVvZVsoH4qZcrGK25VwsXspJv-r9K-",
    "refresh_token": "1//0hwlhrtalKgeRCgYIARAAGBESNwF-",
    "token_uri": "https://oauth2.googleapis.com/token",
    "client_id": "395np.apps.googleusercontent.com",
    "client_secret": "GOCSPXFqoucE03VRVz",
    "scopes": ["https://www.googleapis.com/auth/calendar"],
    "expiry": "2023-02-18T15:30:15.674219Z"
}
creds = Credentials.from_authorized_user_info(creds)

Once you have created the credentials, you can create an instance of the AnalyzerFacade class and use it to analyze your data:

# Choose time range for analysis
start_time = datetime(2023, 3, 1)
end_time = datetime(2023, 3, 18)


async def main():
    async with AnalyzerFacade(creds=creds) as analyzer:
        plot = await analyzer.analyze_one(start_time, end_time, event_name="Programming", plot_type="Line")
        plot.show()

if __name__ == "__main__":
    asyncio.run(main())

What's about multiple plots?

async def main():
    async with AnalyzerFacade(creds=creds) as analyzer:
        coroutines = []
        
        coroutines.append(analyzer.analyze_one(start_time, end_time, event_name="Programming", plot_type="Line")
        coroutines.append(analyzer.analyze_one(start_time, end_time, event_name="Reading", plot_type="Line"))
        coroutines.append(analyzer.analyze_many(start_time, end_time, plot_type="Pie"))
        coroutines.append(analyzer.analyze_many(start_time, end_time, plot_type="Bar"))
                          
        result = await asyncio.gather(*coroutines)
        for plot in result:
            plot.show()

Contribution

If you would like to contribute to this project, please feel free to submit a pull request. Some areas where contributions are particularly welcome include:

  • Adding new features
  • Improving existing features
  • Debugging and fixing bugs
  • Adding tests to ensure the program is working as expected

Analytics example:

Pie plot Bar plot
img img
Line plot Multy line plot
img img

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_calendar_analytics-0.5.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_calendar_analytics-0.5.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file google_calendar_analytics-0.5.0.tar.gz.

File metadata

  • Download URL: google_calendar_analytics-0.5.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.11.0 Darwin/20.6.0

File hashes

Hashes for google_calendar_analytics-0.5.0.tar.gz
Algorithm Hash digest
SHA256 6aea6ae0a4db2d952e6cf5513a827117f60ffbe212a1acdf2245829b4427286a
MD5 f8697301d027dd830ea38c4f7a14113b
BLAKE2b-256 e499a1c58d95c7103146ff5169c6efd662f3ec006bafb3ff29fc2db698228b08

See more details on using hashes here.

File details

Details for the file google_calendar_analytics-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for google_calendar_analytics-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b59b7807abd7b20a4fc8e5f00eb4f29aa63d2aca532d5da213dee0a646d3b3c
MD5 1251684fc870aaf69d4db8c7fb9a6b10
BLAKE2b-256 00a38e1d97c63d081abf70deb04642b4906f87c3005250c38bf1a1e8c05fed6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page