Closed az-data-guru closed 3 years ago
There seems to be an issue with the drill down itself. I ran the template and it through a KeyError.
from tableauscraper import TableauScraper as TS
url = 'https://tableau.azdhs.gov/views/ELR/TestsConducted?%3Aembed=y&'
ts = TS()
ts.loads(url)
wb = ts.getWorkbook()
sheetName = "P1 - Tests by Day W/ % Positivity (Both)"
drillDown1 = wb.getWorksheet(sheetName).levelDrill(drillDown=True, position=1)
drillDown2 = drillDown1.getWorksheet(sheetName).levelDrill(drillDown=True, position=1)
drillDown3 = drillDown2.getWorksheet(sheetName).levelDrill(drillDown=True, position=1)
print(drillDown1.getWorksheet(sheetName).data)
print(drillDown2.getWorksheet(sheetName).data)
print(drillDown3.getWorksheet(sheetName).data)
@az-data-guru You can get the correct data by dropping position=1
since it seems the position is now set to 0
(the default)
I've fixed the key error in any case
The following gets the data:
from tableauscraper import TableauScraper as TS
url = 'https://tableau.azdhs.gov/views/ELR/TestsConducted?%3Aembed=y&'
ts = TS()
ts.loads(url)
wb = ts.getWorkbook()
sheetName = "P1 - Tests by Day W/ % Positivity (Both)"
drillDown1 = wb.getWorksheet(sheetName).levelDrill(drillDown=True)
print(drillDown1.getWorksheet(sheetName).data["MONTH(Collection Date)-alias"])
drillDown2 = drillDown1.getWorksheet(sheetName).levelDrill(drillDown=True)
print(drillDown2.getWorksheet(
sheetName).data["QUARTER(Collection Date)-alias"])
drillDown3 = drillDown2.getWorksheet(sheetName).levelDrill(drillDown=True)
print(drillDown3.getWorksheet(sheetName).data["YEAR(Collection Date)-alias"])
The problem is that the workbook doesn't retain the data so you can get the data between calls, you can get around this for now. I'm working on it
@az-data-guru I've fixed the getWorksheet
and getWorksheets
in the latest release.
Also since last week, the zones are stored in the scraper object, it means than you don't have to pass the last workbook to the next call anymore, since it's shared
For example:
from tableauscraper import TableauScraper as TS
url = 'https://tableau.azdhs.gov/views/ELR/TestsConducted?%3Aembed=y&'
ts = TS()
ts.loads(url)
sheetName = "P1 - Tests by Day W/ % Positivity (Both)"
ws = ts.getWorkbook().getWorksheet(sheetName)
drillDown1 = ws.levelDrill(drillDown=True)
drillDown2 = ws.levelDrill(drillDown=True)
drillDown3 = ws.levelDrill(drillDown=True)
print(drillDown1.getWorksheet(sheetName).data)
print(drillDown2.getWorksheet(sheetName).data)
print(drillDown3.getWorksheet(sheetName).data)
Hey Bertrand,
AZDHS just recently changed their dashboards and the testing tableau now requires that I take two actions on it to get to the data I need. When I try that I get a warning that no data dictonary present in response.
This could just be my weakness with python.
Thanks for the help.