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
def find_next_space(text, start): | |
while start < len(text): | |
if text[start] == " ": | |
return start | |
else: | |
start += 1 | |
return start | |
def find_next_non_space(text, start): | |
while start < len(text): |
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
Get text file from URL, count all the words, and print top 20 words with the number of times they appear in the file. | |
URL: http://www.gutenberg.org/files/5200/5200.txt | |
(please copy this *exact* URL into your code) | |
Sample output: | |
the - 34 | |
a - 12 | |
hello - 5 |
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 multiprocessing import Process, Pipe | |
import sys | |
import time | |
import random | |
def worker(p): | |
while True: | |
s = p.recv() | |
if not s: | |
break |
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 json | |
import unicodecsv as csv | |
import sys | |
def recursive_keys(row): | |
keys = set() | |
for k in row.keys(): | |
if isinstance(row[k], dict): | |
for subkey in recursive_keys(row[k]): |
NewerOlder