Comments (3)
@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.
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.
@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:
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)
released in v0.1.21
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.