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 sys | |
import csv | |
input_file = sys.argv[1] | |
r = csv.reader(open(input_file)) | |
w = csv.writer(sys.stdout) | |
w.writerow(['column','start','length']) | |
for row in r: | |
try: |
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 | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Should use something better than getopt, but this works... | |
Usage: | |
csvcut foobar.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 python | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Should use something better than getopt, but this works... | |
Usage: | |
csvcut foobar.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
strfix <- function(s) { | |
s = gsub("(^ +)|( +$)", "", s) | |
s = sub("^(.*)$","\\U\\1",s, perl=TRUE) | |
return (s) | |
} |
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 | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Leveraged from/motivated by an example from @bycoffe | |
Should use something better than getopt, but this works... |
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 | |
""" | |
Like cut, but for CSVs. To be used from a shell command line. | |
Change row[1] to the row index to be printed. row[1] will print the second | |
item in the row. | |
Note that fields are zero-based, as opposed to 'cut' where they are 1-based. | |
Leveraged from/motivated by an example from @bycoffe |
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 json | |
import os, os.path | |
DEFAULT_PROFILE_NAME = "default.2m2" | |
SESSION_PATH = "Library/Application Support/Firefox/Profiles/%s/sessionstore.js" | |
# TODO consider generalizing the session store to open (different users, different profiles) | |
def session_path(): | |
return os.path.join(os.environ['HOME'],SESSION_PATH % DEFAULT_PROFILE_NAME) |
NewerOlder