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

KeyError: 'zones' returned by getWorkbook() #23

Closed Rhiyo closed 2 years ago

Rhiyo commented 2 years ago

This is occurring with: https://public.tableau.com/views/StatebasedbuildingapprovalsABSNatHERS/NatHERSCertificatesvs_ABSBuildingApprovals

I attempted to see if I could fix the issue by checking to see if zones existed and return an empty string where zones is looked for. I imagine this causes other issues though as there was the only data I could find afterwards was returned by getSheets().

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)

/tmp/ipykernel_78053/2712717284.py in describe_tableau(ts, lines, url)
     10     workbook = ""
     11 
---> 12     workbook = ts.getWorkbook()
     13 
     14 

~/.local/lib/python3.9/site-packages/tableauscraper/TableauScraper.py in getWorkbook(self)
     98 
     99     def getWorkbook(self) -> TableauWorkbook:
--> 100         return dashboard.getWorksheets(self, self.data, self.info)
    101 
    102     def getWorksheet(self, worksheetName) -> TableauWorksheet:

~/.local/lib/python3.9/site-packages/tableauscraper/dashboard.py in getWorksheets(TS, data, info)
     53         worksheets = utils.listWorksheet(presModelMapVizData)
     54     elif presModelMapVizInfo is not None:
---> 55         worksheets = utils.listWorksheetInfo(presModelMapVizInfo)
     56         if len(worksheets) == 0:
     57             worksheets = utils.listStoryPointsInfo(presModelMapVizInfo)

~/.local/lib/python3.9/site-packages/tableauscraper/utils.py in listWorksheetInfo(presModel)
     42 
     43 def listWorksheetInfo(presModel):
---> 44     zones = presModel["workbookPresModel"]["dashboardPresModel"]["zones"]
     45     return [
     46         zones[z]["worksheet"]

KeyError: 'zones'
bertrandmartel commented 2 years ago

@Rhiyo Thanks, that's interesting. It seems it needs the clientDimension parameter when initiating the session to return the zones. I will add this parameter by default but I will first test with some Tableau url to see if it doesn't break anything

bertrandmartel commented 2 years ago

@Rhiyo this is fixed in v0.1.17