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 shutil | |
import os | |
import re | |
source = '/Users/jcur002/Dropbox/Camera Uploads/' | |
files = os.listdir(source) | |
pat = re.compile(r'^(?P<year>20(0[1-2]|1[2-9]|2[0-1]))\-(?P<month>0[1-9]|1[0-2])\-(?P<day>[0][1-9]|[12][0-9]|3[01])[ -](?P<timestamp>.*)\.(?P<extn>gif|png|jpe*g|mts|mp4|mov)$', re.IGNORECASE) |
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 os | |
import re | |
root = '/Users/jcur002/Dropbox/Screenshots' | |
Files = os.listdir(root) | |
pat1 = re.compile('Screenshot (?P<year>[0-9]{4})\-(?P<month>[0-9]{2})\-(?P<day>[0-9]{2}) (?P<hh>[0-9]{2})\.(?P<mm>[0-9]{2})\.(?P<ss>[0-9]{2})(\.png)?') | |
pat2 = re.compile('Screen Shot (?P<year>[0-9]{4})\-(?P<month>[0-9]{2})\-(?P<day>[0-9]{2}) at (?P<hh>[0-9]{1,2})\.(?P<mm>[0-9]{2})\.(?P<ss>[0-9]{2}) *(?P<am>AM|PM)*(\.png)?') | |
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
# A function for matching a parameter pattern with a list of possible parameters | |
# matchParams("b0", c("b0", "b1", "b2", "sigma")) - should return 1 | |
# matchParams("b.", c("b0", "b1", "b2", "sigma")) - should return 1 2 3 | |
# matchParams("b[1-2]", c("b0", "b1", "b2", "sigma")) - should return 2 3 | |
# matchParams(c("b0", "b1"), c("b0", "b1", "b2", "sigma")) - should return 1 2 | |
# matchParams(c("b0", "b1", "b4"), c("b0", "b1", "b2", "sigma")) - should fail because b4 doesn't match | |
# matchParams(c("b0", "b."), c("b0", "b1", "b2", "sigma")) - should return 1 2 3 not 1 1 2 3 as it looks for unique matches | |
matchParams = function(params, paramList){ |
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
# -*- coding: utf-8 -*- | |
import time #only for the example | |
""" | |
This class lets you create a text-based progress bar which updates | |
in place - i.e. it doesn't print to a newline. | |
early all of the code in the print method of this class (called | |
setProgressBar) comes from a stackoverflow post | |
(https://stackoverflow.com/a/34325723/3746992) from user Greenstick | |
(https://stackoverflow.com/users/2206251/greenstick). |
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 csv, re | |
def readHeightsFile(path): | |
heights = [] | |
with open(path, "r", encoding = "utf-8", errors = "ignore") as csvFile: | |
f1 = csv.DictReader(csvFile) | |
for row in f1: | |
heights.append(row["Height"]) |
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
raw | clean | ft | in | mm | |
---|---|---|---|---|---|
"5 | 5'0 | 5 | 0 | 1524 | |
5' | 5'0 | 5 | 0 | 1524 | |
5'5 | 5'5 | 5 | 5 | 1651 | |
5'7 1/2 | 5'7 1/2 | 5 | 7.5 | 1714.5 | |
5'7 | 5'7 | 5 | 7 | 1701.8 | |
5'8.5 | 5'8.5 | 5 | 8.5 | 1739.9 | |
5'612 | 5'6 1/2 | 5 | 6.5 | 1689.1 | |
6'0 1/2 | 6'0 1/2 | 6 | 0.5 | 1841.5 | |
5'4 1/2 ? | 5'4 1/2 ? | 5 | 4.5 | 1638.3 |