tdeBuilder
TdeBuilder is used to create .tde files from input data without having to use tableau desktop. This allows you to schedule .tde file creation using scheduling software. Data can first be joined and or modified using an ETL tool and then dumped to text files. Tdebuilder can read in those text files and create a TDE.
TDE files are compressed and indexes are created on columns that allows for faster reporting and query retrieval in Tableau Desktop. TDE files also use less disk space is than text files.
##Installation
- ./setup.py install
- Alternatively: pip install tdebuilder
- Create needed data using an ETL tool and output data to text files.
- Use tdebuilder.py to create .tde file
- Optional: set JSON settings file to upload .tde to server
- Open .tde file in Tableau Desktop
- Tableau SDK API – downloadable from tableau
- Download: http://onlinehelp.tableau.com/current/api/sdk/en-us/SDK/tableau_sdk_installing.htm#downloading
- Tableau SDK API usage: https://onlinehelp.tableau.com/current/api/sdk/en-us/help.htm
- Tableau SDK API development: http://onlinehelp.tableau.com/current/api/sdk/en-us/SDK/Python/html/index.html
- Python 2.6 or above.
- Download: https://www.python.org/downloads/
JSON is built on two universal structures:
- A collection of name and value pairs.
- An ordered list of values
An object is an unordered set of name and value pairs. An object begins with { (left brace) and ends with} (right brace). Each key if followed by: (colon) and the name value pairs are separated by, (comma).
The last entry in a list should NOT have a comma after it.
Structure
Object
{}
{members}
Members
Pair
Pair,members
Pair
String:value
Array
[]
[elements]
Elements
Value
Value,elements
Value
String
Number
Object
Array
True
False
Null
Example
"columns":{
"Admit Date": "Date",
"Discharge Date":"Date",
"Patient Name": "Text",
"Address":"Text",
"Proc Flag":"Double"
},
There root keys are as follows and are further explained in following chapters:
- parameters : contains a JSON of parameters
- tde_filename
- Contains a string containing the filename to be output to
- input
- Contains a JSON of information about the input data
- columns
- Contains a JSON of column information
- server_upload
- Contains a JSON of server connection information
Example:
{
"parameters":{
"Entity":{
"default":"BHM"
},
"fileExt":{
"default":".txt"
}
},
"tde_filename": "test_$(Entity).tde",
"input":{
"type": "file",
"file_info":{
"input_type":"starname",
"input_file_name":"data$(fileExt)",
"delimiter":"\t",
"column_headers":"column_headers"
}
},
"columns":{
"Admit Date": "Date",
"Discharge Date":"Date",
"Patient Name": "Text",
"Address":"Text",
"Proc Flag":"Double"
},
"server_upload":{
"server_address": "https://blabla.bla.org",
"server_login": "tableau",
"server_password_encoded": "VFl2JnlCYUpHZ0dZe",
"project":"default"
}
}
Parameters are used to replace text in a value. As an example you may want to reuse the same JSON configuration file for two similar input text files. Adding a parameter allows you to reuse your JSON configuration file.
Parameters are defined in the “parameters” key section of the configuration file. Reference a parameter later on in your script like so: $([name]).
Example:
"parameters":{
"Entity":{
"default":"BHM"
},
"fileExt":{
"default":".txt"
}
},
Example of this parameter being used
"tde_filename": "test_$(Entity).tde",
This key is used to set the output name to be given to the .tde file created.
Example
"tde_filename": "test_$(Entity).tde",
This key is used to define input type. Currently the only input type supported is “file”
Input types
- Type
- file - file input; if the type is file then file_info is required
- file_info
- input_type
- starname - read in a list of files using asterisks as a wildcard for multi-file reads
- input_file_name
- name of the input file or files using a wildcard asterisks
- delimiter
- delimiter used in the input file
- columns_headers
- columns_headers – file has column headers
- standard - file does not have column headers use definitions in column section to label files
- input_type
- ** add documentation for odbc**
Example
"input":{
"type": "file",
"file_info":{
"input_type":"starname",
"input_file_name":"data$(fileExt)",
"delimiter":"t",
"column_headers":"column_headers"
}
},
Column name is the key and the value is equal to the data type the column should be. This key is a sub key of the “input” key.
The following data types are allowed:
- Bit
- Boolean True or False
- Example: 1,0
- Byte
- A whole number
- Example: 123
- Short
- A number with a decimal
- Example: 123.222
- Long
- A number with a decimal
- Example: 123.222
- Integer
- A whole number
- Example: 1235455
- Single
- A whole number
- Example: 55332
- Double
- A number with a decimal
- Example: 223434.22325423
- Date
- A date in the required format
- Format: YYYY-MM-DD or YYYYMMDD
- Example: 2016-02-21
- DateTime
- A date and time in the required format
- date in format YYYY-MM-DD HH:MM:SS.mm
- Example: 2016-02-02 01:05:22.23
- Text
- long text info
- Example: “John Doe”
- Memo
- long text info
- Example: “John Doe”
Example
"columns":{
"Admit Date": "Date",
"Discharge Date":"Date",
"Patient Name": "Text",
"Address":"Text",
"Proc Flag":"Double"
},
This key is used to set server settings to upload the .tde to tableau server. If this key is not in the JSON configuration the upload process is not attempted.
1. server_upload
1. server_address - address of your tableau server
2. server_login - username to log in
3. server_password_encoded - encoded password using the –p switch via the command line. (see Password Encode)
4. project - project to upload the data source
Example
"server_upload":{
"server_address": "https://bla.bla.org",
"server_login": "tableau",
"server_password_encoded": "VFl2JnlCYUpHZ0d"
}
Passwords for the server upload configuration must first be scrambled using the –p switch via the command line.
Usage: tdeBuilder.py - [password]
The output will be the password to be entered into the server_upload |serverpassword_encoded field in your JSON settings file.
Example
C:\\projects\\tableau\\extract>python tdeBuilder.py -p pass1234Blue
encoded password: cGFzczEyMzRCbHVl
Usage: tdeBuilder.py –p [password]
The output will be the password to be entered into the server_upload |serverpassword_encoded field in your JSON settings file.
Example
C:\\projects\\tableau\\extract>python tdeBuilder.py -p pass1234Blue
encoded password: cGFzczEyMzRCbHVl
Via the command line
python tdeBuilder.py -i [JSON configuration]