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

Issue selecting Parameter in Story Point #47

Open markbaird opened 2 years ago

markbaird commented 2 years ago

I'm trying to scrape the data here. In the browser I scroll to the "Cases Demographics" item at the top, which appears to be a Story Point. After selecting that I then select the "Age" radio button. Finally I am able to click Download -> Crosstab -> Excel and get the data I need.

I'm trying to use your library to automate this process. I can see the "Cases Demographics" in the storypoints list that comes back, and I'm able to select that. After selecting the storypoint I can see the different parameters available. But as soon as I select the "Age" parameter (or any of the available parameters) I just get this error and no data:

tableauScraper - WARNING - no data dictionary present in response

Also after selecting the story point, if I call getWorksheetNames() on the storypoint I just get an empty list.

Here is my code:

from tableauscraper import TableauScraper as TS

url = "https://public.tableau.com/views/NCDHHS_COVID-19_DataDownload_Story_16220681778000/DataBehindtheDashboards"
ts = TS()
ts.loads(url)
workbook = ts.getWorkbook()

print(workbook.getStoryPoints())
sp = workbook.goToStoryPoint(storyPointId=6)

# show parameters values / column
parameters = workbook.getParameters()
print(parameters)
workbook = workbook.setParameter(inputName="Select Demographic", value="Age")
print(sp.getWorksheetNames())

for ws in workbook.worksheets:
    print(f"worksheet name : {ws.name}")
    print(ws.data)

And the output:

{'storyBoard': 'DataBehindtheDashboards', 'storyPoints': [[{'storyPointId': 1, 'storyPointCaption': 'Daily Cases and Deaths Metrics'}, {'storyPointId': 16, 'storyPointCaption': 'Daily Cases and Deaths Metrics by County \n'}, {'storyPointId': 2, 'storyPointCaption': 'Daily Testing Metrics'}, {'storyPointId': 15, 'storyPointCaption': 'Percent Positive by County'}, {'storyPointId': 17, 'storyPointCaption': 'County Cases and Deaths \n'}, {'storyPointId': 4, 'storyPointCaption': 'ZIP Code Cases and Deaths'}, {'storyPointId': 5, 'storyPointCaption': 'Demographics'}, {'storyPointId': 6, 'storyPointCaption': 'Cases Demographics'}, {'storyPointId': 7, 'storyPointCaption': 'Outbreaks and Clusters'}, {'storyPointId': 8, 'storyPointCaption': 'Personal Protective Equipment (PPE)'}, {'storyPointId': 9, 'storyPointCaption': 'Hospital Patient Data'}, {'storyPointId': 10, 'storyPointCaption': 'Hospital Beds and Ventilators'}, {'storyPointId': 11, 'storyPointCaption': 'Hospital Demographics'}, {'storyPointId': 12, 'storyPointCaption': 'Vaccinations - Doses by County '}, {'storyPointId': 13, 'storyPointCaption': 'People Vaccinated by County '}, {'storyPointId': 14, 'storyPointCaption': 'People Vaccinated Demographics'}, {'storyPointId': 18, 'storyPointCaption': 'Wastewater Monitoring'}]]} 2021-12-08 17:14:01,366 - tableauScraper - WARNING - no data dictionary present in response [{'column': 'Select Demographic', 'values': ['Race', 'Ethnicity', 'Age', 'Gender', 'Birth through K-12'], 'parameterName': '[Parameters].[Parameter 2 1]'}] 2021-12-08 17:14:03,302 - tableauScraper - WARNING - no data dictionary present in response []

paulobh commented 1 year ago

This library is amazing!

Just a similar issue probably related with some updates on the source: https://replit.com/@bertrandmartel/TableauONSDemandaMaxima

The other thing I was trying was to use the goToStoryPoint() with the setParameter() but the data was not updated, maybe on updateFullData()?

print(wb.getStoryPoints())
# print("go to specific storypoint")
sp = wb.goToStoryPoint(storyPointId=5)

sp = sp.setParameter("Escala de Tempo CE Comp 3", "Dia")

on the example above it was expected to set the period frequency to daily however it only shows the default value (monthly).

I'm still trying to understand what might be the issue...