This file contains hidden or 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
#!/usr/bin/env python | |
# | |
# $Id: Nielsen2010Python_sqlspeed.py,v 1.3 2010/11/15 00:59:14 fn Exp $ | |
import os | |
import random | |
import sqlite3 | |
import time | |
conversion = { 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", |
This file contains hidden or 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
#!/usr/bin/env python | |
# | |
# $Id: Royal2008Whats.py,v 1.2 2011/04/05 15:40:37 fn Exp $ | |
from pylab import * | |
from scipy.signal import medfilt | |
from scipy.stats.stats import spearmanr | |
from urllib import FancyURLopener, urlopen, urlencode | |
import sys | |
reload(sys) |
This file contains hidden or 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
# $Id: Nielsen2011Median.py,v 1.1 2011/05/04 12:21:30 fn Exp $ | |
from pylab import * | |
from scipy.signal import medfilt | |
from numpy import median | |
def g(): | |
"""Generator for data points""" | |
if rand() < 0.90: return 12 + randn() | |
else: return 12 + 10 * randn() |
This file contains hidden or 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
#!/usr/bin/env python | |
# | |
# $Id: Wehner2011Trusselrapporter.py,v 1.3 2011/05/12 17:07:21 fn Exp $ | |
import csv | |
from pylab import * | |
from urllib import urlopen | |
url = 'http://data.information.dk/warlogs/afghanistan/data/wl_threat_reports.csv' |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import sys | |
texts = [ open(filename).read().split() for filename in sys.argv[1:]] | |
maxlength = [ max(map(len, t)) for t in texts ] | |
for line in zip(*texts): | |
print("".join([ line[n] + " " * (maxlength[n] - len(line[n]) + 1) for n in range(len(line)) ])) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import sys | |
texts = [ open(filename).read().split() for filename in sys.argv[1:]] | |
maxlength = [ max(map(len, t)) for t in texts ] | |
print("\n".join(["".join([ line[n] + " " * (maxlength[n] - len(line[n]) + 1) for n in range(len(line)) ]) for line in zip(*texts) ])) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import itertools, sys | |
texts = [ open(filename).read().split() for filename in sys.argv[1:]] | |
maxlength = [ max(map(len, t)) for t in texts ] | |
print("\n".join(["".join([ line[n] + " " * (maxlength[n] - len(line[n]) + 1) for n in range(len(line)) ]) for line in itertools.zip_longest(*texts, fillvalue="") ])) |
This file contains hidden or 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 itertools,sys | |
t=[open(f).read().split()for f in sys.argv[1:]] | |
m=[max(map(len,u)) for u in t] | |
print("\n".join(["".join([l[n]+" "*(m[n]-len(l[n])+1)for n in range(len(l))])for l in itertools.zip_longest(*t,fillvalue="")])) |
This file contains hidden or 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 itertools,sys | |
t=[open(f).read().strip().split("\n")for f in sys.argv[1:]] | |
for l in itertools.zip_longest(*t,fillvalue=""):print(" ".join([l[n].ljust(max(map(len,t[n])))for n in range(len(l))])) |
This file contains hidden or 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
#!/usr/bin/env python | |
import math, sys # Importing modules. | |
def formatresult(res): # Define function. Remember colon! | |
"""This is the documentation for a function.""" | |
return "The result is %f" % res # Percentage for formating | |
if len(sys.argv) < 3: # Conditionals should be indended | |
print("Too few input argument") |
OlderNewer