Code Monkey home page Code Monkey logo

Comments (8)

paulrxn007 avatar paulrxn007 commented on May 27, 2024 1

@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.

bertrandmartel avatar bertrandmartel commented on May 27, 2024

@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.

paulrxn007 avatar paulrxn007 commented on May 27, 2024

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.

bertrandmartel avatar bertrandmartel commented on May 27, 2024

@paulrxn007 what is your code ?

from tableau-scraping.

paulrxn007 avatar paulrxn007 commented on May 27, 2024
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.

bertrandmartel avatar bertrandmartel commented on May 27, 2024

@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.

paulrxn007 avatar paulrxn007 commented on May 27, 2024

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.

bertrandmartel avatar bertrandmartel commented on May 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.