bertrandmartel / tableau-scraping

Tableau scraper python library. R and Python scripts to scrape data from Tableau viz
MIT License
126 stars 20 forks source link

Persist parameters info payload when calling consecutive commands #33

Closed bertrandmartel closed 2 years ago

bertrandmartel commented 2 years ago

From this url https://tableau.ons.org.br/t/ONS_Publico/views/DemandaMxima/HistricoDemandaMxima?:embed=y&:display_count=y&:showAppBanner=true&:showVizHome=y the parameter list is lost when calling consecutive commands for example:

from tableauscraper import TableauScraper as TS

url = 'https://tableau.ons.org.br/t/ONS_Publico/views/DemandaMxima/HistricoDemandaMxima'
ts = TS()
ts.loads(url)
wb = ts.getWorkbook()
print(wb.getParameters())

# Set units
wb = wb.setParameter("Selecione DM Simp 4", "Demanda Máxima Instântanea (MW)")
print(wb.getParameters())

# Set to daily resolution
wb = wb.setParameter("Escala de Tempo DM Simp 4", "Dia")

Output

[{'column': 'Fim Primeiro Período DM Simp 4', 'values': [], 'parameterName': '[Parameters].[Fim Primeiro Período DM Simp 4]'}, {'column': 'Início Primeiro Período DM Simp 4', 'values': [], 'parameterName': '[Parameters].[Início Primeiro Período DM Simp 4]'}, {'column': 'Escala de Tempo DM Simp 4', 'values': ['Ano', 'Mês', 'Semana Operativa', 'Dia'], 'parameterName': '[Parameters].[Escala do Tempo DM Simp 4]'}, {'column': 'Selecione DM Simp 4', 'values': ['Demanda Máxima Horária (MWh/h)', 'Demanda Máxima Instântanea (MW)'], 'parameterName': '[Parameters].[Parameter 1]'}]

[{'column': 'Selecione DM Simp 4', 'values': ['Demanda Máxima Horária (MWh/h)', 'Demanda Máxima Instântanea (MW)'], 'parameterName': '[Parameters].[Parameter 1]'}]

2021-10-03 06:12:45,754 - tableauScraper - ERROR - column Escala de Tempo DM Simp 4 not found

One solution is to keep original info payload along with the info of the cmd response