Created
October 5, 2014 15:41
-
-
Save ghing/f99a2cdef7df97efa1e9 to your computer and use it in GitHub Desktop.
Grab a row from an Excel spreadsheet and output it. Useful for extracting test cases for OpenElections loaders from source results.
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 argparse | |
import xlrd | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Extract rows from an Excel ' | |
'file.') | |
parser.add_argument('filename', nargs=1, | |
help='Excel file to load row from') | |
parser.add_argument('rows', nargs='+', | |
help='Row numbers to extract') | |
args = parser.parse_args() | |
sheet = xlrd.open_workbook(args.filename[0]).sheets()[0] | |
for row_index in args.rows: | |
row_index = int(row_index) | |
print(sheet.row_values(row_index)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment