Skip to content

Instantly share code, notes, and snippets.

View brettclare's full-sized avatar

Brett Clare brettclare

View GitHub Profile
#http://www.marinamele.com/use-google-analytics-api-with-python
import httplib2
from googleapiclient.discovery import build
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client import tools
import argparse
CLIENT_SECRETS = 'client_secrets.json'
Enter file contents here#https://github.com/jay0lee/GAM/wiki/CreatingClientSecretsFile
#https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/installed-py#run
"""A simple example of how to access the Google Analytics API."""
#need a working WORK account with admin privliges, that is why the page doesn't come up
import httplib2
from googleapiclient.discovery import build
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client import tools
Enter file contents hereimport pypyodbc
connection_string = ("Driver={SQL Server};Server=sql_xx_reporting;Database=xx;Trusted_Connection=Yes;")
connection = pypyodbc.connect(connection_string)
cur = connection.cursor()
#SQL=('SELECT * FROM tbl_twitter_stream')
SQL=("insert into tbl_twitter_stream(tweetID ,tweetText,tweetRetweetCt,tweetFavoriteCt,tweetSource,tweetCreated,userID,userScreen,userName ,userCreateDt,"
"userDesc,userFollowerCt,userFriendsCt,userLocation,userTimezone)Values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
Values=['723581579696607232','Breeeet Juice and they will send you...','0','0','Prospect street','2016-04-22 18:37:46','794315930',
'derekdoane55', 'Derek Doane','2012-08-31 17:31:26' ,'sc: derek_doane','242','9','San Diego, CA','Pacific Time (US & Canada)']
Enter file contents hereimport csv
import requests
from bs4 import BeautifulSoup
url = 'http://log.concept2.com/rankings/2016/rower/5000?age=50-59&weight=H&gender=M&status=verified'
response = requests.get(url)
html = response.content
soup=BeautifulSoup(html)
Enter file contents here#http://blog.impiyush.me/2015/03/data-analysis-using-twitter-api-and.html
#http://stackoverflow.com/questions/27555343/python-ms-access-database-table-creation-from-pandas-dataframe-using-sqlalchemy
import tweepy
import pandas as pd
# only goes back one week
access_key = "xxx"
access_key_secret ="xxx"
consumer_key ="xxY"
Enter file contents hereimport tweepy
#from tweepy.api import API
access_key = "xxxx"
access_key_secret ="xxxx"
consumer_key ="xxY"
consumer_secret ="xxx"
auth = tweepy.OAuthHandler("xxY", "xxx")
auth.set_access_token("xxxS","xxx")
Enter file contents hereimport pandas
import webbrowser
import select
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common import keys
browser = webdriver.Firefox()
type(browser)
data_df=pandas.read_csv('C:\Code\ASN_example.csv',sep=",",header=0,index_col=False)
Enter file contents here # -*- coding: utf-8 -*-
import pypyodbc,csv
pypyodbc.lowercase = False
conn = pypyodbc.connect(
r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};" +
r"Dbq=H:\GamePlanMaster\GamePlanMaster 2.accdb;")
cur = conn.cursor()
for table_name in cur.tables(tableType='TABLE'):
print(table_name)
cur.execute("SELECT * FROM WMS_worksheet_OPS_Plan_linked")