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
# return list of bill numbers extracted from string | |
import re | |
def extract_legislation(haystack): | |
haystack = haystack.upper() | |
p = re.compile('S\.?\s?CON\.?\s?RES\.?\s?\d{1,5}|H\.?\s?CON\s?RES\.?\s?\d{1,5}|S\.?\s?J\.?\s?RES\.?\s\d{1,5}|H\.?\s?J\.?\s?RES\.?\s\d{1,5}|S\.?\s?RES\.?\s?\d{1,5}|H\.?\s?RES\.?\s?\d{1,5}|H\.?\s?\R\.?\s?\d{1,5}|S\.?\s?\d{1,5}') | |
needle_list = p.findall(haystack) | |
return needle_list |
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 re | |
# return list of public law numbers extracted from string | |
def extract_laws(haystack): | |
p = re.compile('P\.L\.\s?\d{1,3}-\d{1,3}') | |
needle_list = p.findall(haystack) | |
return needle_list |
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 re | |
#extract CRS report order codes from string and return as list | |
def extract_ordercodes(haystack): | |
p = re.compile('R\d{5}|RL\d{5}|RS\d{5}|IB\d{5}') | |
needle_list = p.findall(haystack) | |
return needle_list |
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 re | |
#extract GAO report ID's from text and return as a list | |
def extract_gao_id(haystack): | |
p = re.compile('GAO-\d{2}-?\d{1,4}\w?') | |
needle_list = p.findall(haystack) | |
return needle_list |
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
#returns number of Congress in session for provided year | |
def congress_from_year(year): | |
if year < 1789: | |
return None | |
else: | |
return int((year-1789)/2) + 1 |
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 datetime, time | |
import urllib2 | |
from BeautifulSoup import BeautifulSoup | |
#returns list of GAO reports for past year | |
def grab_gao(): | |
doc_type = "GAO" | |
page = urllib2.urlopen("http://gao.gov/docsearch/pastyear.html") | |
soup = BeautifulSoup(page) | |
report_list = [] |
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
#python string date to date | |
date_str = "June 8, 1976" | |
release_date = time.strftime('%Y-%m-%d', time.strptime(date_str, '%B %d, %Y')) |
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
#returns session number of Congress for a provided year | |
def session_from_year(year): | |
return 2 - (year % 2) |
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
#songsincode | |
def another(): | |
return "you've been messing around" | |
def friend(x): | |
return another() if x else friend(1) | |
i=friend(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
TRICEPHALE | |
#1 | |
A WRAP + A 1 0 15 | |
IF G.FDR.EN A: Y A; X 1; $ 5 | |
$ 6 | |
EVERY 64: $ 4 | |
#2 |
OlderNewer