Skip to content

Instantly share code, notes, and snippets.

View scottx611x's full-sized avatar

Scott Ouellette scottx611x

View GitHub Profile
@scottx611x
scottx611x / spinner.py
Last active June 7, 2016 12:49 — forked from empiricalthought/spinner.py
Python 2 compatible ASCII spinner for progress feedback
import itertools
import sys
def spinner(granularity):
"""Wraps a function in an ASCII spinner display loop. granularity
represents the number of times the function should be called
before moving the spinner."""
spinner_chars = itertools.cycle("\|/-")
def make_spinner(f):
calls = {'x': 0}
__author__ = 'scott'
with open('massachusetts_municipalities.txt', 'r') as inf, open('interleaved_list2.txt', 'w') as out:
A,B,C =[],[],{}
A += [item.strip() for item in inf]
for item in A:
if not item[0] in C: C[item[0]] = []
C[item[0]].append(item)
B += [C[key] for key in sorted(C)]
while B:
if [] in B: B.remove([])