Last active
April 9, 2017 07:47
-
-
Save swayson/1cac797a7781f353397d2ef3bd9eb531 to your computer and use it in GitHub Desktop.
Simple utility command line tool to list the sheet names of an Excel workbook.
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
""" | |
Simple utility command line tool to list the sheet names of an Excel workbook. | |
""" | |
import argparse | |
from xlrd import open_workbook | |
def get_args(): | |
"""This function parses and return command line arguments""" | |
parser = argparse.ArgumentParser(description='List sheetnames in Excel workbook.') | |
parser.add_argument('filename', metavar='f', type=str, help='Filename') | |
args = parser.parse_args() | |
return args | |
if __name__ == '__main__': | |
wb = open_workbook(get_args().filename) | |
for sheet in wb.sheets(): | |
print(sheet.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment