- Zen of Python (wherein all your questions are answered)
import thisYour humble guides (ping us):
| """ | |
| *** SERDAR's NOTES **** | |
| This is a good start. There are a few minor issues that I've noted in the code towards the top of the file, | |
| specifically in the "main" and "group_members_by_party" functions. Please read the notes I added to the top half of the | |
| file and try to fix the code before moving on to the sorting and printing steps. | |
| Let me know if you have any questions. |
| # No need for creating new directories with this script. Note, if you were to use "mkdir-p" it requires a path to a directory | |
| # as its argument. For example, "mkdir -p ~/code/example" | |
| # mkdir -p | |
| # cd code | |
| curl -s --output banklist.csv https://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/banklist.csv | |
| # No need to touch the file | |
| # touch ca_failed_banks.csv | |
| # Instead, create it using head | |
| head -1 banklist.csv > ca_failed_banks.csv | |
| # You should delete extraneous commands not needed by the script such as below "cat" statement |
| { | |
| "01001": 0, | |
| "01003": 1, | |
| "01005": 0, | |
| "01007": 0, | |
| "01009": 0, | |
| "01011": 0, | |
| "01013": 0, | |
| "01015": 0, | |
| "01017": 0, |
| { | |
| "Items": [ | |
| { | |
| "site_type": { | |
| "S": "municipality" | |
| }, | |
| "country": { | |
| "S": "United States" | |
| }, | |
| "endpoint": { |
| import csv | |
| import os | |
| import urllib.request | |
| url = 'https://www.fdic.gov/bank/individual/failed/banklist.csv' | |
| source_file = os.path.expanduser('~/Desktop/failed_banks.csv') | |
| urllib.request.urlretrieve(url, source_file) | |
| with open(source_file, 'r', encoding="latin-1") as failed_banks: |
| ### Gemfile ### | |
| cd ~/test | |
| less Gemfile | |
| source 'https://rubygems.org' | |
| gem 'fech', git: 'https://github.com/NYTimes/Fech.git', :tag => 'v1.8', :submodules => true | |
| #### CLI output #### | |
| # Below run by a user with no ssh keys | |
| ~/test$ bundle |
| """ | |
| A monstrosity of an election results script. Calculates total votes for | |
| races and candidates, and determines if there is a winner in each race. | |
| This module bundles together way too much functionality and is near impossible | |
| to test, beyond eye-balling results. | |
| USAGE: | |
| python election_results.py |
import thisYour humble guides (ping us):
| import csv, urllib | |
| from operator import itemgetter | |
| from collections import defaultdict | |
| from os.path import dirname, join | |
| url = "https://docs.google.com/spreadsheet/pub?key=0AhhC0IWaObRqdGFkUW1kUmp2ZlZjUjdTYV9lNFJ5RHc&output=csv" | |
| filename = join(dirname(dirname(__file__)), 'fake_va_elec_results.csv') | |
| urllib.urlretrieve(url, filename) | |
| reader = csv.DictReader(open(filename, 'rb')) |
| ~/code/ruby/ap/devops/vmfarm/puppet/private> cd projects/ | |
| ~/code/ruby/ap/devops/vmfarm/puppet/private/projects> pwd | |
| /Users/stumgoren/code/ruby/ap/devops/vmfarm/puppet/private/projects | |
| ~/code/ruby/ap/devops/vmfarm/puppet/private/projects> git branch -a | |
| error: object directory /root/.r10k/git/https---git.ap.org-puppet-puppet-projects.git/objects does not exist; check .git/objects/info/alternates. | |
| master | |
| remotes/cache/master | |
| remotes/origin/HEAD -> origin/master | |
| remotes/origin/master | |
| ~/code/ruby/ap/devops/vmfarm/puppet/private/projects> git remote show |