import tempfile, shutil, os, sys, json

from mmap import mmap, ACCESS_READ
from xlrd import open_workbook
from pprint import pprint

# keep track of row indexes for each sheet
def main():
    args = sys.argv[1:]
    if not args:
        raise Exception('path to template excel workbook argument not supplied')
    template_workbook_path = args[0]
    book = open_workbook(template_workbook_path)
    get_sheet_titles(book);
def get_sheet_titles(book):
    output = []
    for idx, sheet_name in enumerate(book.sheet_names()):
        sheet_data = {
            'index': idx,
            'name': sheet_name
            }
        output.append(sheet_data)
    print (json.dumps(output))
try:    
    main()
except Exception, e:
        sys.stderr.write(str(e))
        raise e
