bertrandmartel / tableau-scraping

Tableau scraper python library. R and Python scripts to scrape data from Tableau viz
MIT License
126 stars 20 forks source link

getFilters() only returns the first 200 values #69

Open anapaulazampier opened 1 year ago

anapaulazampier commented 1 year ago

Hii @bertrandmartel , first of all thank you so much for your work, it's amazing! I'm facing issues on the same dashboard as @khrusco (issue #29). When calling getFilters() it only returns the first 200 values from the value field and I would like to create a database with all "agentes" values. Here's my code:

import pandas as pd
from tableauscraper import TableauScraper as TS

url = "https://tableaupub.ccee.org.br/t/PIDM/views/IndicadoresdeSeguranadoMercado/ConcentraodeNegociao"

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

print("parametros:")
print(workbook.getParameters())
print("------------------------")

workbook = workbook.setParameter('parDimensão', 'Agente')
ws = workbook.getWorksheet('Classe Contraparte')

print("filtros:")
print(ws.getFilters())
print("------------------------")

filtros = ws.getFilters()
agentes = filtros[0]['values']

appended_data = pd.DataFrame()
for x in agentes:
    print(x)
    wb = ws.setFilter('Filtro Dimensão', x , membershipTarget=False, filterDelta=True, dashboardFilter=True)
    df_aux = wb.getWorksheet('Hist Concentração de Negociação (2)').data
    df_aux['agente'] = x
    appended_data = appended_data.append(df_aux)

Thanks in advance for you help! :)