Skip to content

Instantly share code, notes, and snippets.

@swayson
Last active April 9, 2017 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swayson/1cac797a7781f353397d2ef3bd9eb531 to your computer and use it in GitHub Desktop.
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.
"""
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