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

Setting a filter produces `WARNING - no data dictionary present in response` and causes `getCsvData` to raise `TypeError` #76

Open Kodiologist opened 6 months ago

Kodiologist commented 6 months ago

The following appears to work, although it takes a while (about two and a half minutes).

import tableauscraper
url = 'https://a816-healthtableau.nyc.gov/t/HDI-EPIQUERY/views/HDISurveillanceModules_syndromic/IndicatorbyNeighborhood'
  # From https://a816-health.nyc.gov/hdi/epiquery/visualizations?PageType=ts&PopulationSource=Syndromic
ts = tableauscraper.TableauScraper()
ts.loads(url)
wb = ts.getWorkbook()
print(wb.getCsvData(sheetName = 'IBN: Map').shape)
  # => (399592, 91)

By contrast, this

import tableauscraper
url = 'https://a816-healthtableau.nyc.gov/t/HDI-EPIQUERY/views/HDISurveillanceModules_syndromic/IndicatorbyNeighborhood'
ts = tableauscraper.TableauScraper()
ts.loads(url)
filtered = ts.getWorksheet('IBN: Map').setFilter('Ind1Name', 'Respiratory')
print(filtered.getCsvData(sheetName = 'IBN: Map').shape)

produces

2023-12-13 11:41:48,207 - tableauScraper - WARNING - no data dictionary present in response
Traceback (most recent call last):
  File "/tmp/example.py", line 8, in <module>
    print(filtered.getCsvData(sheetName = 'IBN: Map').shape)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[…]/lib/python3.11/site-packages/tableauscraper/TableauWorkbook.py", line 194, in getCsvData
    if ("workbookPresModel" in presModel) and ("dashboardPresModel" in presModel["workbookPresModel"]) and ("viewIds" in presModel["workbookPresModel"]["dashboardPresModel"]):
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

I'm using version 0.1.29 of the library from PyPI.