In which we list tips, tricks, and reminders.
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
#!/usr/bin/env python | |
''' | |
Generate a unique primary key ID based on a combination of | |
subject, session, and row (optionally) IDs. | |
''' | |
epilog = ''' | |
Note that one can use positional args instead of named args. |
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
#!/usr/bin/env python | |
''' | |
Convert a TSV-formatted file to a set of SQL insert or update statements. | |
''' | |
import argparse | |
from datastore.table import Reader | |
parser = argparse.ArgumentParser(description=__doc__) | |
parser.add_argument('--mode', choices=('insert', 'update'), default='update') |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
'''xls2tsv - print the contents of a worksheet from an excel workbook.''' | |
import sys | |
import xlrd | |
import optparse | |
parser = optparse.OptionParser() |
Note: see the fence repo for enhanced npm-packaged version of this script.
Convert your literate script to a GH-flavored code-fenced variant.
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
''' | |
Read in a TSV (tab-separated values) file as an array of dicts. | |
Usage: | |
r = Reader('tests/tsv/init.tsv') | |
print r | |
print r.rows | |
print r.column('name') | |
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
console.log new Date().toString().split(' ')[1..3].join('-') # M-D-Y |