10000 support file with geocoding in it · ManuelVoiden/document-api-python@dbfd2a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit dbfd2a5

Browse files
committed
support file with geocoding in it
1 parent cf80554 commit dbfd2a5

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

samples/list-tds-info/geocoding.twbx

65.1 MB
Binary file not shown.
Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
############################################################
22
# Step 1) Use Datasource object from the Document API
33
############################################################
4-
from tableaudocumentapi import Datasource
4+
from tableaudocumentapi import Workbook
55

66
############################################################
7-
# Step 2) Open the .tds we want to replicate
7+
# Step 2) Open the .tds we want to explore
88
############################################################
9-
sourceTDS = Datasource.from_file('world.tds')
9+
sourceTWBX = Workbook('geocoding.twbx')
1010

1111
############################################################
12-
# Step 3) List out info from the TDS
12+
# Step 3) List out info from the TWBX
1313
############################################################
1414
print('----------------------------------------------------------')
15-
print('-- Info for our .tds:')
16-
print('-- name:\t{0}'.format(sourceTDS.name))
17-
print('-- version:\t{0}'.format(sourceTDS.version))
15+
print('-- Info for our .twbx:')
16+
print('-- name:\t{0}'.format(sourceTWBX.filename))
17+
print('-- CONTENTS')
18+
print('-- dashboards:\t{0}'.format(len(sourceTWBX.dashboards)))
19+
for dash in sourceTWBX.dashboards:
20+
print("-- {}".format(dash))
21+
22+
print('-- datasources:\t{0}'.format(len(sourceTWBX.datasources)))
23+
for data in sourceTWBX.datasources:
24+
print("-- {}".format(data.name))
25+
26+
print('-- worksheets:\t{0}'.format(len(sourceTWBX.worksheets)))
27+
for data in sourceTWBX.worksheets:
28+
print("-- {}".format(data))
29+
30+
print('-- shapes:\t{0}'.format(len(sourceTWBX.shapes)))
31+
for shape in sourceTWBX.shapes:
32+
print("-- {}".format(shape))
1833
print('----------------------------------------------------------')

samples/show-fields/show_fields.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# Step 3) Print out all of the fields and what type they are
1313
############################################################
1414
print('----------------------------------------------------------')
15+
print('-- Info for our .tds:')
16+
print('-- name:\t{0}'.format(sourceTDS.name))
17+
print('-- version:\t{0}'.format(sourceTDS.version))
18+
print('----------------------------------------------------------')
1519
print('--- {} total fields in this datasource'.format(len(sourceTDS.fields)))
1620
print('----------------------------------------------------------')
1721
for count, field in enumerate(sourceTDS.fields.values()):

tableaudocumentapi/xfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def xml_open(filename, expected_root=None):
3838

3939
# Does the root tag match the object type (workbook or data source)
4040
if expected_root and (expected_root != tree_root.tag):
41+
if expected_root == 'workbook' and tree_root.tag == 'datasource':
42+
return # A .twbx can contain .tds files if it contains custom geocoding.
4143
raise TableauInvalidFileException(
4244
"'{}'' is not a valid '{}' file".format(filename, expected_root))
4345

0 commit comments

Comments
 (0)
0