Skip to content

Instantly share code, notes, and snippets.

View calistatee's full-sized avatar

Calista calistatee

View GitHub Profile
@calistatee
calistatee / python_text_editor
Last active January 30, 2018 04:22
Python: Build your own text editor
from tkinter import *
from tkinter.filedialog import *
filename = None
# create new file
def newFile():
global filename
filename = "Just Write"
text.delete(0.0, END)
@calistatee
calistatee / python_web_scraping_beautifulsoup.txt
Last active January 31, 2018 03:50
Python: Web Scraping with BeautifulSoup
from bs4 import BeautifulSoup
import requests
import csv
# request web source to get source code
source = requests.get('insert your url here').text
# assign a var for parsed information w standard BS syntax
soup = BeautifulSoup(source, 'lxml')
@calistatee
calistatee / python_write_csv.txt
Last active January 27, 2018 01:43
Python: Write CSV Files
#this is a template for you to write a csv file
import csv
# create a file to open
# 'w' = write mode
# new line = blank
with open('name your csv file', 'w', newline = '') as fp:
# create var
a = csv.writer(fp, delimiter = ',')
@calistatee
calistatee / python_twitter_sentiment_analysis.txt
Last active January 9, 2024 08:59
Python: Twitter and Sentiment Analysis
import tweepy
import csv
from urlextract import URLExtract
from textblob import TextBlob
# log in via codes provided by Twitter
consumer_key = 'enter your consumer key'
consumer_secret = 'enter your consumer secret key'
access_token = 'enter your access token'
@calistatee
calistatee / python_tweet_update.txt
Last active January 27, 2018 01:45
Python: How to post new status update from your terminal
import tweepy
# log in via codes provided by Twitter
consumer_key = 'enter your consumer key'
consumer_secret = 'enter your consumer secret'
access_token = 'enter your access token'
access_token_secret = 'enter your access token secret'
# this is for authentication by using OAuthHandler and set_access_token method