This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv, sys | |
# This is a quick and dirty solution to walk the file that Travis County distributes | |
# the day after the election and create a new .csv file that has one row per race | |
# per precinct with the winner and his/her/its vote percentage | |
# | |
# CLI usage: python travis-elex-formatter.py input_file.csv output_file.csv | |
last_field = None | |
winner_total_votes = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def list_files(source, extension): | |
matches = [] | |
for root, dirnames, filenames in os.walk(source): | |
for filename in filenames: | |
if filename.endswith((extension)): | |
print filename | |
# Ex: Get all files in the directory docs with the extension PDF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests, csv | |
# Settings | |
base_url = 'http://www.schiefferschool.tcu.edu/' | |
story_list_url = 'more_headlines.asp' | |
blacklist = ['931.htm', '1021.asp'] | |
# Get a list of articles to scrape from the More Headlines page | |
news_page = requests.get(base_url + story_list_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = // Webhook URL | |
var text = // Text to post | |
$.ajax({ | |
data: 'payload=' + JSON.stringify({ | |
"text": text | |
}), | |
dataType: 'json', | |
processData: false, | |
type: 'POST', | |
url: url |
NewerOlder