tableau / document-api-python

Create and modify Tableau workbook and datasource files
https://tableau.github.io/document-api-python/
MIT License
326 stars 178 forks source link

Hidden property doesn't work as expected. #244

Open dev-mkc19 opened 1 year ago

dev-mkc19 commented 1 year ago

Hi. Release 0.10 brought ability to get status of field, either it hidden or not. But in fact Tableau workbook doesn't contain xml attribute for every field, only for hidden. So after initialisation Workbook object if you check fields you will see two values False or None.

But code and docstring inside hidden method tells that as a user I should expect only True False values. Am I right that it's a bug and None values have to be handled?

Code to reproduce:

import tableaudocumentapi
wb = tableaudocumentapi.Workbook('CheckBook_2021.2_sql.twb')
import pandas as pd

fs = []
for s in wb.datasources:
    for k in s.fields:
        try:
            id = s.fields[k].id
        except:
            pass
        try:
            name = s.fields[k].name
        except:
            pass
        try:
            caption = s.fields[k].caption
        except:
            pass
        try:
            calculation = s.fields[k].calculation
        except:
            pass
        try:
            hidden = s.fields[k].hidden
        except:
            pass

        fs.append({'ds': s.caption,
                    'id': id,
                'name': name,
                'caption': caption,
                'calculation': calculation,
                'hidden': hidden
                    })
df = pd.DataFrame.from_records(fs)
df

Result:

image

CheckBook_2021.2_sql.twb.zip