for field in datasource.fields.values():
        field_attributes = [
            field.id, field.caption, field.alias, field.datatype, field.role,
            field.is_quantitative, field.is_ordinal, field.is_nominal,
            field.calculation, field.default_aggregation, field.description
        ]
        print(field_attributes)


# file_name = "C:\\Users\\jj2362\\Desktop\\docs in\\standard frequent flyer.tds"
file_name = "C:\\Users\\jj2362\\Desktop\\Sheet1 (Visual_Analytics_TOC_DataSimulated).tds"
# file_name = "C:\\Users\\jj2362\\Desktop\\docs in\\Master.twb"

file_type = xml_open(file_name)

base = file_type.getroot()
print(base.tag)

if base.tag == 'datasource':
    document = tableaudocumentapi.Datasource.from_file(file_name)
    process_datasources(document)
else:
    document = Workbook(file_name)
    for datasource in document.datasources:
        process_datasources(datasource)
        print("")

# for datasource in workbook.datasources:

test = Field()
print(test._attributes)
Exemple #2
0
 def test_field_throws_if_no_data_passed_in(self):
     with self.assertRaises(AttributeError):
         Field()