diff --git a/samples/show-fields/show_fields.py b/samples/show-fields/show_fields.py index 84cdd44..8a90758 100644 --- a/samples/show-fields/show_fields.py +++ b/samples/show-fields/show_fields.py @@ -2,6 +2,9 @@ # Step 1) Use Datasource object from the Document API ############################################################ from tableaudocumentapi import Datasource +import lxml.etree +from xml.etree import ElementTree, ElementInclude +import xml.etree.ElementTree as ET ############################################################ # Step 2) Open the .tds we want to inspect @@ -15,17 +18,35 @@ print('--- {} total fields in this datasource'.format(len(sourceTDS.fields))) print('----------------------------------------------------------') for count, field in enumerate(sourceTDS.fields.values()): - print('{:>4}: {} is a {}'.format(count+1, field.name, field.datatype)) - blank_line = False - if field.calculation: - print(' the formula is {}'.format(field.calculation)) - blank_line = True - if field.default_aggregation: - print(' the default aggregation is {}'.format(field.default_aggregation)) - blank_line = True - if field.description: - print(' the description is {}'.format(field.description)) + print(type(field)) - if blank_line: - print('') + # print(field.name) + # # print(field.datatype) + # # print(field.role) + print(field.type) + # if field.description is not None: + # print(field.description.tag) + # # This will get the raw description from an element + # print(field.description[0][0]) + # else: + # print("No Description") + + # print(type(field.description)) + print('-' * 70) + + + + # print('{:>4}: {} is a {}'.format(count+1, field.name, field.datatype)) + # blank_line = False + # if field.calculation: + # print(' the formula is {}'.format(field.calculation)) + # blank_line = True + # if field.default_aggregation: + # print(' the default aggregation is {}'.format(field.default_aggregation)) + # blank_line = True + # if field.description: + # print(' the description is {}'.format(field.description)) + # + # if blank_line: + # print('') print('----------------------------------------------------------') diff --git a/tableaudocumentapi/field.py b/tableaudocumentapi/field.py index 88d5b3b..33e55a8 100644 --- a/tableaudocumentapi/field.py +++ b/tableaudocumentapi/field.py @@ -358,6 +358,7 @@ def _read_calculation(xmldata): @staticmethod def _read_description(xmldata): description = xmldata.find('.//desc') + # description = xmldata.find('.//run') if description is None: return None @@ -367,3 +368,4 @@ def _read_description(xmldata): description_string = description_string.decode('utf-8') return description_string + # return description