Comments (8)
@bertrandmartel I don't get how it works in your code, but when I copy from yours to mine, no go.
Maybe i need to start one from scratch
from tableau-scraping.
@paulrxn007 This library reproduces the same behaviour as in the UI, you can set one parameter after another like in the UI using consecutive setParameter
.
For Ohio Covid dashboard I have an example to get every county data https://replit.com/@bertrandmartel/TableauCovidOhio using setParameter
from tableau-scraping.
hey @bertrandmartel
thanks for replying so fast and for the tip of consecutive setParameter.
What I am seeing now is this error from the counties loop...
Traceback (most recent call last):
File "main.py", line 46, in
workbook = maptotal.select("County ", county)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/tableauscraper/TableauWorksheet.py", line 227, in select
self.updateFullData(r)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/tableauscraper/TableauWorksheet.py", line 39, in updateFullData
dataSegments = presModel["dataDictionary"]["dataSegments"]
KeyError: 'dataDictionary'
How do I figure out these dictionary levels? I always feel like I'm missing something
from tableau-scraping.
@paulrxn007 what is your code ?
from tableau-scraping.
from tableauscraper import TableauScraper as TS
import pandas as pd
url = "https://public.tableau.com/views/OverviewDashboard_15852499073250/DashboardOverview_1"
ts = TS()
ts.loads(url)
workbook = ts.getWorkbook()
searchfilter = ts.getWorksheet("Search Filter")
maptotal = ts.getWorksheet("County Map | Total")
linetotal = ts.getWorksheet("Line | Total Cases")
sideside = ts.getWorksheet("Side By Side Comparison")
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
parameters = workbook.getParameters()
print(parameters)
counties = [
t["values"] for t in maptotal.getSelectableItems()
if t["column"] == "County " ][0]
print(counties)
# set parameters column / value
workbook.setParameter("Parameter - Case Type", "Probable")
#workbook.setParameter("Parameter - Cumulative","Daily Count")
#workbook.setParameter("Parameter County","County of Residence")
workbook.setParameter("Parameter - Start Date",'2021-09-17')
for county in counties:
print(county)
workbook = maptotal.select("County ", county)
print(workbook.data)
from tableau-scraping.
@paulrxn007 The output of setParameter
is a new workbook. In order to persist the session with multiple call, you can reuse the workbook variable like this workbook = workbook.setParameter(...)
.
It seems that the date uses a format DD/MM/YYYY
not sure why
The following sets the parameters and retrieves each county for the resulted workbook:
from tableauscraper import TableauScraper as TS
import pandas as pd
url = "https://public.tableau.com/views/OverviewDashboard_15852499073250/DashboardOverview_1"
ts = TS()
ts.loads(url)
workbook = ts.getWorkbook()
maptotal = workbook.getWorksheet("County Map | Total")
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
counties = [
t["values"] for t in maptotal.getSelectableItems()
if t["column"] == "County "][0]
print(counties)
# set parameters column / value
workbook = workbook.setParameter("Parameter - Case Type", "Probable")
workbook = workbook.setParameter("Parameter - Start Date", '17/09/2021')
maptotal = workbook.getWorksheet("County Map | Total")
for county in counties:
print(county)
tempWb = maptotal.select("County ", county)
ws = tempWb.getWorksheet("Text | Total Cases")
print(ws.data)
https://replit.com/@bertrandmartel/TableauCovidOhio2
from tableau-scraping.
hey there @bertrandmartel Tableau expert,
So, now I am running into an issue with not finding the End Date parameter, but it is there. Any clues about that? I have tried different places for the Parameter, but no change.
_```
[{'column': 'Parameter County', 'values': ['County of Residence', 'County of Death'], 'parameterName': '[Parameters].[Parameter 8]'}, {'column': 'Parameter - Start Date', 'values': [], 'parameterName': '[Parameters].[Parameter 9]'}, {'column': 'Parameter - End Date', 'values': [], 'parameterName': '[Parameters].[Parameter - Start Date (copy)_1926696252560949248]'}, {'column': 'Parameter - Cumulative', 'values': ['Cumulative Count', 'Daily Count'], 'parameterName': '[Parameters].[Parameter 7]'}, {'column': 'Parameter - Comparison', 'values': ['Age', 'County', 'Sex'], 'parameterName': '[Parameters].[Parameter 1]'}, {'column': 'Parameter - Case Type', 'values': ['(All) Total Cases', 'Confirmed', 'Probable'], 'parameterName': '[Parameters].[Parameter 5]'}, {'column': 'Parameter - Map', 'values': ['Cases', 'Deaths', 'Hospitalizations'], 'parameterName': '[Parameters].[Parameter 2]'}]
2021-10-05 13:31:00,768 - tableauScraper - ERROR - column Parameter - End Date not found
Wyandot
2021-10-05 13:31:03,153 - tableauScraper - WARNING - no data dictionary present in response
AGG(Daily Case Count)-alias
0 72
Wood
AGG(Daily Case Count)-alias
0 308
Williams
from tableau-scraping.
@paulrxn007 without your code, I can't understand what's the issue, adding Parameter - End Date
parameter in the previous code works for me
from tableau-scraping.
Related Issues (20)
- Issue selecting Parameter in Story Point HOT 1
- getTupleIds fail to run when `presModel` is None
- Can't set a Parameter if not listed in getParameters() HOT 2
- Can't set a filter to a value thats not in the defined list for that filter HOT 2
- add missing method for command `select-region-no-return-server` HOT 1
- Add getFilterItems() method
- Scraping tableau data based on data filtered with dropdown boxes in non existent worksheet columns
- Adding range filters
- soup.find fails to find Tableau data HOT 3
- Scraping from a private-access dashboard
- scraping workbook, NOT worksheet with selectables HOT 6
- Attempting to fetch data from sheet but can't get worksheets using getWorksheets(), most requests are returning empty arrays.
- Zones don't always update when there are story points
- getFilters() only returns the first 200 values
- How to scrape pagination data
- Radio Button filtering does not work
- Warning: mixed data types
- Add support for the 'Choose a format to download' > 'Data' option (alongside the crosstab option)
- Issue w/ filtering and parameters/selectable items HOT 1
- Setting a filter produces `WARNING - no data dictionary present in response` and causes `getCsvData` to raise `TypeError`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tableau-scraping.