Giter Site home page Giter Site logo

google_api's Introduction

python-read-gmail

Setup

  • Set up the conda envrionment "google-api":

      $ conda env create -f environment.yml 
    
  • Follow these instructions to allow python to access your gmail account (skip the past about installing python packages, thats already taken care of in the conda envionment"):

    https://developers.google.com/gmail/api/quickstart/python

  • After the set up you will download a file called credentials.json. Be sure to update the variable GMAIL_CREDENTIALS_PATH path to this file in example.py. Also update the GMAIL_TOKEN_PATH to be a file called *-token.json in the same directory

    e.g:

    example.py 
    
    GMAIL_CREDENTIALS_PATH = "credentials.json"
    GMAIL_TOKEN_PATH = "token.json"
    ...
    

Usage

API Documentation is here: https://developers.google.com/resources/api-libraries/documentation/gmail/v1/python/latest/

  • Use this function to get the gmail service and access to all messages (taken from the quickstart.py code):
example.py
...
from google_api import gmail

# get all attachments from e-mails containing 'test'
search_query = "test"
service = gmail.get_gmail_service(GMAIL_CREDENTIALS_PATH, GMAIL_TOKEN_PATH)
results = gmail.query_for_csv_or_xl_attachments(service, search_query)

# 1st Attachment found:
item = results[0]
df = item['data']
print('email: ' + item['emailsubject'])
print('filename: ' + item['filename'])
print("data sample: ")
print(df.head())

google_api's People

Contributors

robertdavidwest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.