def get_file(title=None, fmt='dict', **kwargs):
    """
    Simple interface for grabbing a Google Drive file by title.  Retrieves
    file in xlsx format and parses with pandas.ExcelFile If keyword argument `sheet` is given,
    returns only specified sheet.
    args:
        title     (str)   : Title of Google Drive document
        fmt       (str)   : Determines the format of the return value.
                            list of accepted formats and the corresponding return value type:
                            * `dict`           : list of dicts (Default).
                            * `pandas`         : pandas.DataFrame
                            * `list`           : list of lists
                            * `pandas_excel`   : Pandas.ExcelFile, (not yet parsed) useful for custom parsing
                            For all formats other than `pandas_excel`, if no sheet name is given and the spreadsheet
                            contains more than one sheet, get_file returns a dict with sheet names as keys and accordingly
                            formatted sheets as values.
    kwargs:
        sheet     (str)   : name of sheet to return
        cache     (str)   : location in which to store the cached contents of files
        usecache  (bool)  : whether to use the cache (default is False), but useful for debugging
        config    (str)   : path from which to read the config file which contains credentials
        store     (str)   : location in which to store file-specific credentials
        header    (int)   : which row to use as the header. use None for no header in which case
                            column names will be X1, X2, ...
        

    """
    opts = default_options()
    opts['title'] = title
    opts.update((k,v) for k, v in load_config(opts).items() if v is not None)
    opts.update((k,v) for k, v in kwargs.items())
    logger.info('opts:\n%s', pprint.pformat(opts))
    #pprint.pprint(opts)
    if opts['title'] is None:
        raise ValueError('`title` not found in options.  exiting')

    content = get_content(opts)
    wb = pd.ExcelFile(StringIO.StringIO(content))

    if fmt == 'pandas_excel':
        return wb
   
    try:
        parsed_wb = OrderedDict([(sheet_name, wb.parse(sheet_name, header=opts['header'])) for sheet_name in wb.sheet_names])
    except:
        print 'error parsing worksheet using pandas.ExcelFile.parse(sheet_name). '\
              'Consider using the pandas_excel fmt in get_file and parsing the fileA '\
              'yourself to have more control'
        logger.exception('error parsing worksheet using pandas.ExcelFile.parse(sheet_name). '
                         'Consider using the pandas_excel fmt in get_file and parsing the file '
                         'yourself to have more control')
        raise

    if fmt == 'list':
        fmt_wb = OrderedDict([(name, list(df.itertuples(index=False))) for name, df in parsed_wb.items()])
    elif fmt == 'dict':
        fmt_wb = OrderedDict([(name, [r[1].to_dict() for r in df.iterrows()]) for name, df in parsed_wb.items()])
    elif fmt == 'pandas':
        fmt_wb = parsed_wb
    else:
        raise ValueError('unkown format: %s' % fmt)
    if len(fmt_wb) == 1:
        return fmt_wb.values()[0]
    if 'sheet' in opts:
        try:
            return fmt_wb[opts['sheet']]
        except:
            print 'sheet name: `%s` not found in workbook.  sheet_names: %s' % (opts['sheet'], fmt_wb.keys())
            logger.exception('sheet name: %s not found in workbook.  sheet_names: %s', opts['sheet'], fmt_wb.keys())
            raise
    else:
        return fmt_wb
dataset/ETHPy150Open embr/gcat/gcat/__init__.py/get_file/original