コード例 #1
0
def getCmdResponse(TS, data, logger):
    presModel = data["vqlCmdResponse"]["layoutStatus"]["applicationPresModel"]

    zonesWithWorksheet = utils.selectWorksheetCmdResponse(presModel, logger)
    dataFull = utils.getDataFullCmdResponse(presModel, TS.dataSegments)
    output = []
    for selectedZone in zonesWithWorksheet:
        frameData = utils.getWorksheetCmdResponse(selectedZone, dataFull)

        if frameData is None:
            continue

        df = pd.DataFrame.from_dict(frameData, orient="index").fillna(0).T

        output.append(
            TableauWorksheet(
                scraper=TS,
                originalData=data,
                originalInfo={},
                worksheetName=selectedZone["worksheet"],
                dataFrame=df,
                dataFull=utils.getDataFullCmdResponse(presModel,
                                                      TS.dataSegments),
                cmdResponse=True,
            ))
    return TableauWorkbook(scraper=TS,
                           originalData=data,
                           originalInfo={},
                           data=output,
                           cmdResponse=True)
コード例 #2
0
def get(TS, data, info, logger):
    output = []
    worksheets = utils.selectWorksheet(data, logger)

    for worksheet in worksheets:
        df = getWorksheet(TS, data, info, worksheet)
        output.append(df)

    return TableauWorkbook(scraper=TS,
                           originalData=data,
                           originalInfo=info,
                           data=output)
コード例 #3
0
def get(TS, data, info, logger):
    worksheets = utils.selectWorksheet(data, logger, single=True)
    if len(worksheets) == 0:
        return TableauWorkbook(scraper=TS,
                               originalData=data,
                               originalInfo=info,
                               data=[])
    selectedWorksheet = worksheets[0]

    presModel = utils.getPresModelVizData(data)
    result = utils.getIndicesInfo(presModel,
                                  selectedWorksheet,
                                  noSelectFilter=False)

    for idx, t in enumerate(result):
        logger.info(f"[{idx}] {t['fieldCaption']}")

    selected = input(f"select field by index : ")

    if (selected is None) or (selected == ""):
        raise (Exception("you must select at least one field"))
    field = result[int(selected)]
    logger.info(f"you have selected {field['fieldCaption']}")

    dataFull = utils.getDataFull(presModel, TS.dataSegments)
    frameData = utils.getData(dataFull, [field])
    frameDataKeys = list(frameData.keys())

    if len(frameDataKeys) == 0:
        raise (Exception("no data extracted"))

    data = frameData[frameDataKeys[0]]
    for idx, t in enumerate(data):
        logger.info(f"[{idx}] {t}")

    selected = input(f"select value by index : ")
    if (selected is None) or (selected == ""):
        raise (Exception("you must select at least one value"))
    value = data[int(selected)]
    logger.info(f"you have selected {value}")

    r = api.select(TS, selectedWorksheet, [int(selected) + 1])
    return dashboard.getCmdResponse(TS, r, logger)
コード例 #4
0
def getWorksheets(TS, data, info) -> TableauWorkbook:

    presModelMapVizData = utils.getPresModelVizData(data)
    presModelMapVizInfo = utils.getPresModelVizInfo(info)
    if presModelMapVizData is not None:
        worksheets = utils.listWorksheet(presModelMapVizData)
    elif presModelMapVizInfo is not None:
        worksheets = utils.listWorksheetInfo(presModelMapVizInfo)
        if len(worksheets) == 0:
            worksheets = utils.listStoryPointsInfo(presModelMapVizInfo)
    else:
        worksheets = []

    output = []
    for worksheet in worksheets:
        df = getWorksheet(TS, data, info, worksheet)
        output.append(df)

    return TableauWorkbook(scraper=TS,
                           originalData=data,
                           originalInfo=info,
                           data=output)