Code Monkey home page Code Monkey logo

Comments (3)

bertrandmartel avatar bertrandmartel commented on May 28, 2024

@galalH Thanks, there seems to be something missing in the filter-by-index implementation

One example in python would be:

from tableauscraper import TableauScraper as TS

url = "https://publicstats.cbp.gov/t/PublicFacing/views/CBPSBOEnforcementActionsDashboardsJULFY21/SBOEncounters7139?:embed=y&:showVizHome=no&:host_url=https%3A%2F%2Fpublicstats.cbp.gov%2F&:embed_code_version=3&:tabs=no&:toolbar=yes&:showAppBanner=false&:showShareOptions=%E2%80%99false%E2%80%99&:display_spinner=no&:loadOrderID=0"

ts = TS()
ts.loads(url)
wb = ts.getWorkbook()

ws = ts.getWorksheet("SBO Line Graph")
print(ws.data)

# get filters columns and values
filters = ws.getFilters()
print(filters)


# set filter value
wb = ws.setFilter('Citizenship Grouping', 'El Salvador')

# show the new data for worksheet
ws = wb.getWorksheet("SBO Line Graph")
print(ws.data)

But doesn't return any data

The current implementation doesn't deal with filter-delta type which uses these params:

filterUpdateType: filter-delta
filterAddIndices: [1]
filterRemoveIndices: [0]

The current implementation always set filterUpdateType to filter-replace:

("filterIndices", (None, json.dumps(selection))),
("filterUpdateType", (None, "filter-replace"))

I need to look at the json result to understand how to set the filterUpdateType accordinglyand how to figure out filterAddIndices and filterRemoveIndices

from tableau-scraping.

rodrigues-pedro avatar rodrigues-pedro commented on May 28, 2024

I randomly get the same Warning, like 1 out of 20 tries it just doesn't get the data.
Same filters applied, most times it work, but sometimes it doesn't.

It's kinda frustrating since I don't know what could be the cause....
This is the code right now

  url = "https://public.tableau.com/views/ExcessoObitos-confernciadedados/ExcessodebitosRevisado"
  ts = TS()
  
  i = 0
  df = pd.DataFrame()
  
  while i<=5 & df.empty:
      ts.loads(url)
      wb = ts.getWorkbook()
      ws = wb.getWorksheet("Curva UF")
      
      df = ws.data
      i += 1
      
      if df.empty:
          time.sleep(5*60)

Am I doing something wrong? Do you think is a problem with the tableau panel itself?

To contextualize a little bit, it's part of one indicator on a automatically generated report that runs every sunday. It's important that it is generated on sunday due to some indicators that relate to epidemiologic week.

from tableau-scraping.

bertrandmartel avatar bertrandmartel commented on May 28, 2024

@rodrigues-pedro could you create another issue about it ?

I've just implemented the filter-delta that checks the selected option in the filter configuration (if any selection exists) and removes those selection index and add the filter index:

selected

I've also added the possibility to input an array of filter to setFilter, it will correctly deal with multiple filter index when using filter-replace or filter delta

Example:

from tableauscraper import TableauScraper as TS

url = "https://publicstats.cbp.gov/t/PublicFacing/views/CBPSBOEnforcementActionsDashboardsJULFY21/SBOEncounters7139"

ts = TS()
ts.loads(url)
wb = ts.getWorkbook()

ws = ts.getWorksheet("SBO Line Graph")
print(ws.data)

# get filters columns and values
filters = ws.getFilters()
print(filters)

# set filter value
wb = ws.setFilter('Citizenship Grouping', 'El Salvador', filterDelta=True)

# show the new data for worksheet
ws = wb.getWorksheet("SBO Line Graph")
print(ws.data)

wb = ws.setFilter('Citizenship Grouping', 'Guatemala', filterDelta=True)

# show the new data for worksheet
ws = wb.getWorksheet("SBO Line Graph")
print(ws.data)

wb = ws.setFilter('Citizenship Grouping', [
                  'Guatemala', 'El Salvador'], filterDelta=True)

# show the new data for worksheet
ws = wb.getWorksheet("SBO Line Graph")
print(ws.data)

Try this on repl.it

released in v0.1.21

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.