8000 TCS-152 · onware/document-api-python@a332eb6 · GitHub
[go: up one dir, main page]

Skip to content

Commit a332eb6

Browse files
author
Sam Bao
committed
TCS-152
#Time 3h ability to change branch for multiple tableau workbook
1 parent 9ae5583 commit a332eb6

File tree

7 files changed

+95084
-12
lines changed

7 files changed

+95084
-12
lines changed

samples/filter-and-replicate/Job Time - Abbotsford-Cor.twb

Lines changed: 24292 additions & 0 deletions
Large diffs are not rendered by default.

samples/filter-and-replicate/Job Time - Abbotsford-Ref.twb

Lines changed: 24292 additions & 0 deletions
Large diffs are not rendered by default.

samples/filter-and-replicate/Job Time - Edmonton.twb

Lines changed: 24292 additions & 0 deletions
Large diffs are not rendered by default.

samples/filter-and-replicate/Job Time.twb

Lines changed: 22169 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Workbook,Format,Project,Branch
2-
Job Time,twbx,Operations - Edmonton,Edmonton
3-
Job Time,twbx,Operations - Abbotsford-Cor,Abbotsford-Cor
4-
Job Time,twbx,Operations - Abbotsford-Ref,Abbotsford-Ref
1+
Workbook,Format,Project,Branch
2+
Job Time,.twb,Operations - Edmonton,Edmonton
3+
Job Time,.twb,Operations - Abbotsford-Cor,Abbotsford-Cor
4+
Job Time,.twb,Operations - Abbotsford-Ref,Abbotsford-Ref
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import csv # so we can work with our database list (in a CSV file)
2-
32
############################################################
43
# Step 1) Use Workbook object from the Document API
54
############################################################
@@ -12,15 +11,18 @@
1211
with open('databases.csv') as csvfile:
1312
databases = csv.DictReader(csvfile, delimiter=',', quotechar='"')
1413
for row in databases:
15-
14+
1615
# Open the workbook
17-
sourceWB = Workbook(row['Filename'] + row['Format'])
16+
sourceWB = Workbook(row['Workbook'] + row['Format'])
1817

1918
# Update the filters
20-
for datasource in sourceWB.datasources:
21-
for filter in datasource:
22-
if filter.column == '[Branch]'
23-
filter.groupfilter.member = '"' + row['Branch'] + '"'
19+
for datasource in reversed(sourceWB.datasources):
20+
for children in datasource._datasourceTree._root._children:
21+
if "column" in children.attrib and "class" in children.attrib:
22+
if children.attrib["column"] == "[Branch]" and children.attrib["class"] == "categorical":
23+
for subchildren in children._children:
24+
if "member" in subchildren.attrib:
25+
subchildren.attrib["member"] = '"' + row['Branch'] + '"'
2426

2527
# Save our newly created workbook with the new file name
26-
sourceWB.save_as(row['Filename'] + ' - ' + row['Branch'] + row['Format'])
28+
sourceWB.save_as(row['Workbook'] + ' - ' + row['Branch'] + row['Format'])
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<SchemaVersion>2.0</SchemaVersion>
6+
<ProjectGuid>{e9772cb6-1e47-4d77-9065-9e6995218d0c}</ProjectGuid>
7+
<ProjectHome />
8+
<StartupFile>filter-and-replicate.py</StartupFile>
9+
<SearchPath />
10+
<WorkingDirectory>.</WorkingDirectory>
11+
<OutputPath>.</OutputPath>
12+
<ProjectTypeGuids>{888888a0-9f3d-457c-b088-3a5042f75d52}</ProjectTypeGuids>
13+
<LaunchProvider>Standard Python launcher</LaunchProvider>
14+
<InterpreterId />
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
17+
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
18+
<PropertyGroup>
19+
<VisualStudioVersion Condition=" '$(VisualStudioVersion)' == '' ">10.0</VisualStudioVersion>
20+
</PropertyGroup>
21+
<ItemGroup>
22+
<Compile Include="filter-and-replicate.py" />
23+
</ItemGroup>
24+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
25+
</Project>

0 commit comments

Comments
 (0)
0