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 | |
| # This top line tells the computer that your script is an executable | |
| # Let's save this file as xxxxx_cleanup.py | |
| # Today we have a datafile in csv (comma separated values) format which is not | |
| # clean. There are inconsistencies in text formats, | |
| # Base python comes with a lot of capabilities, but just like in R, we have to | |
| # import different packages or "modules" in python to allow us to do more. We |
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
| # From a list of bad dates: | |
| import csv | |
| from datetime import datetime | |
| input_file = "bad_dates.csv" | |
| output_file = "good_dates.csv" | |
| with open(output_file, 'wb') as open_file: | |
| writer = csv.writer(open_file, dialect='excel') | |
| with open(input_file, 'rU') as csvfile: | |
| reader = csv.DictReader(csvfile) |
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 os | |
| import glob | |
| import csv | |
| import itertools | |
| from os.path import basename | |
| from collections import OrderedDict | |
| from datetime import datetime | |
| # |
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/python | |
| """GPX_to_csv_waypoints.py: Exporting waypoints in GPX file to a csv file""" | |
| # Author: Jillian Dunic | |
| # Date created: 2014-08-13 | |
| #------------- | |
| # Change log # |
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
| -- Basis of most of this taken from: https://github.com/miromannino/miro-windows-management | |
| local mash = {"cmd", "ctrl"} | |
| local mash2 = {"ctrl", "alt"} | |
| local toggle = false | |
| local VOLUME_INC = 10 | |
| local sizes = {1, 3, 2, 3/2} | |
| local fullScreenSizes = {1, 4/3, 2} |
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
| # Good discussion on str_extract/str_match and positive look behind | |
| # https://stackoverflow.com/questions/35804379/stringr-str-extract-how-to-do-positive-lookbehind | |
| dms2dec <- function(string) { | |
| string <- | |
| str_squish(string) %>% | |
| str_replace_all(., "\\s", "") | |
| values <- str_match(string, "(\\d*)[\\u00B0|˚]\\s?(\\d*\\.?\\d*?)('|′|’)\\s?(\\d*?\\.?\\d*?)[\"|″]?\\s?(N|n|E|e|S|s|W|w)") | |
| original <- values[, 1] |
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
| data(major, package = "PBSdata") | |
| data(pmfc, package = "PBSdata") | |
| pmfc_sf <- as_tibble(major) |> | |
| st_as_sf(coords = c("X", "Y"), crs = "WGS84") |> | |
| group_by(PID) |> | |
| summarise(geometry = st_combine(geometry)) |> | |
| st_cast("POLYGON") |> | |
| left_join(pmfc, by = c("PID" = "major")) |> | |
| tidyr::separate(name, into = c("code", "name"), sep = ": ") |