Skip to content

Instantly share code, notes, and snippets.

View hancush's full-sized avatar
🍓

hannah cushman garland hancush

🍓
View GitHub Profile
@hancush
hancush / expenditures.csv
Last active June 17, 2024 14:04
NMID record examples
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 32 columns, instead of 4 in line 3.
OrgID,Expenditure Amount,Expenditure Date,Payee Last Name,Payee First Name,Payee Middle Name,Payee Prefix,Payee Suffix,Payee Address 1,Payee Address 2,Payee City,Payee State,Payee Zip Code,Description,Expenditure ID,Filed Date,Election,Report Name,Start of Period,End of Period,Purpose,Expenditure Type,Reason,Stance,Report Entity Type,Committee Name,Candidate Last Name,Candidate First Name,Candidate Middle Name,Candidate Prefix,Candidate Suffix,Amended
1397,13.0000,3/18/2024 12:00:00 AM,Bank of America,,,,,3101 Southern Blvd,,Rio Rancho,NM,87124,Bank Fees,324284,3/18/2024 3:28:55 PM,2024 Primary,First Bi-Annual Report,Oct 3 2023 12:00AM,Apr 1 2024 12:00AM,Other,Monetary Expenditures,,,Candidate,Espinoza For NM,Espinoza,Diego ,L.,,,N
1645,0.5000,1/9/2024 12:00:00 AM,ActBlue,,,,,PO Box 441146,,Somerville,MA,02144,,1142065,4/5/2024 3:49:29 PM,2024 Primary,First Primary Report,Oct 3 2023 12:00AM,Apr 1 2024 12:00AM,Other,Other,,,PAC,Democratic Party of Los Alamos County,,,,,,N
1645,0.7900,2/1/2024 12:00:00 AM,A
<iframe src="https://docs.google.com/spreadsheets/d/e/2PACX-1vSeTcW7T-iNX26MU1FzqfPXKXe3Vqzg8dvztrOVqC7dDKtomdzF3MrvUspgXEiEsEAY3ii0KdDPVvzy/pubhtml?gid=0&amp;single=true&amp;widget=true&amp;headers=false"></iframe>
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 4 in line 1.
Candidate,Votes Total,Votes Percent
"Anthony ""Tony"" Ciaravino",0,0.0,
Ambria Taylor,0,0.0,
"Elvira ""Vida"" Jimenez",0,0.0,
Nicole Lee,0,0.0,
"Froylan ""Froy"" Jimenez",0,0.0,
Steve Demitro,0,0.0,
Don Don,0,0.0,
0 of 23 precincts reporting,,
---
title: "Geocoding template"
output: html_notebook
---
# Instructions
- Upload your file to the data/ directory of this workspace by clicking Upload in the menu bar of the file browser in the lower right pane. Make note of the name of the column containing the addresses you want to geocode.
- Follow these instructions to get an API key for the Google Geocoding API in the Google Console: https://developers.google.com/maps/documentation/geocoding/cloud-setup
- N.b., You have to set up a billing account to use the Google Geocoding API. See details on pricing here: https://developers.google.com/maps/documentation/geocoding/usage-and-billing#pricing-for-product

My R Version:

call-me-hank:analysis-drug-charges hannah$ Rscript --version
R scripting front-end version 4.0.0 (2020-04-24)

After the first round of errors, I uninstalled everything using uninstall.R, then ran install.R. (Both are attached to this gist, for reference.) Here are some excerpts from the output.

Seems like a few packages are not available

$(patsubst %, pensions_%.reordered.csv, $(shell seq 2012 1 2017)) : data/raw/pensions_2012-2017.csv
# some other operations on the downloaded/inflated pensions data
data/raw/pensions_%.csv : data/raw/pensions_%.tar
cd $(dir $@) && tar xvfz $(notdir $<)
data/raw/pensions_%.tar :
wget --no-use-server-timestamps \
https://bga-pensions-database.s3.amazonaws.com/raw/$(notdir $@) -O $@
response = requests.post(some_post_data)
response_data = json.loads(response.data.decode('utf-8'))
print(response_data)
# {
# "status": "ok",
# "matches": [
# {
from lxml import etree
html = '''
<h3>Offense: A Tale of Two Halves</h3>
<p>For a while there, it seemed the Bears' offense might never show up in London. The unit generated just two first downs and 44 total yards in the first half. Then <strong>Chase Daniel</strong> s
tarted hitting his spots, aided with some stellar work by <strong>Allen Robinson</strong> and <strong>Anthony Miller</strong>, to get the rally going. Unfortunately, it was too little, too late wi
th the defense not playing at its best.</p>
<h5>By the numbers:</h5>
<ul>
<li><strong>194 PASSING YARDS:</strong> Daniel had some good moments in completing 22 of 30 passes for 231 yards, but <a href="https://chicago.suntimes.com/bears/2019/10/6/20901945/daniel-takes-th
Employer ID
City of Chicago 16
Chicago 16
Metropolitan Pier and Exposition Authority 53
Metropolitan Pier Exposition Authority 53
Third Lake 364
Village Of Third Lake 364
Fox Valley Park District 519
Fox Valley Park District 519
Homewood Flossmoor Park District 541
# usage: python interval.py /path/to/your/file.csv
import csv
import sys
import re
def days_from_interval(interval):
if interval == 'never':
return None