Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ script:
# Examples
- (cd "Examples/Replicate Workbook" && python replicateWorkbook.py)
- (cd "Examples/List TDS Info" && python listTDSInfo.py)
- (cd "Examples/GetFields" && python show_fields.py)

1 change: 1 addition & 0 deletions Examples/GetFields/World.tds
29 changes: 29 additions & 0 deletions Examples/GetFields/show_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
############################################################
# Step 1) Use Datasource object from the Document API
############################################################
from tableaudocumentapi import Datasource

############################################################
# Step 2) Open the .tds we want to inspect
############################################################
sourceTDS = Datasource.from_file('World.tds')

############################################################
# Step 3) Print out all of the fields and what type they are
############################################################
print('----------------------------------------------------------')
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.aggregation:
print(' the default aggregation is {}'.format(field.aggregation))
blank_line = True

if blank_line:
print('')
print('----------------------------------------------------------')