Friday, November 15, 2013

tabadmin set commands — Tableauing Tableau

The Tableau Public workbook below contains dashboards I put together to help me organize and interpret the various options available for the Tableau Server tabadmin set command.

Although the set command information is available in Tableau's online help here it's in a static HTML table, and I find it a lot more useful to have it in data so I can use Tableau to organize, filter, and reshuffle it in various ways when building my mental map of how the options relate to one another.

You can use the dashboards from Tableau public or download the workbook. Or if you're interested in how I got the online help content into data I've put that information below.

Rendering the online help table as data.
Since the HTML table is no-frills you can simply copy and paste it into Tableau. This works perfectly well since there are no HTML tags inside the table's cells to confuse Tableau. But its wasn't quite what I was after.

There are links in the options' descriptions that the copy/paste into Tableau method doesn't capture. I thought it helpful to have these so I whipped up a little Ruby script to parse the HTML and extract everything into a CSV file. And since the Jet engine hasn't yet been replaced (but soon, soon) I split the descriptions into 250-character sections, and recombined them with a calculated field after extracting the data into a TDE.

Using the Ruby script has several dependencies:

  • it's a Ruby script so your machine must be able to run Ruby, and you must have permissions to do so (sometimes not so easy in a corporate environment);
  • it uses some non-standard Ruby gems (libraries) so these need to be installed on your system – this is usually very straightforward and a quick Google will show the way;
  • you really should be comfortable with this level of technical stuff – if you're not there's likely someone nearby who can help, or you can always contact me.


# TTC_TabadminHelpToDataTv8.rb - this Ruby script Copyright 2013, Christopher Gerrard require 'nokogiri' require 'open-uri' $recNum = 0 $Tv8HelpRoot = 'http://onlinehelp.tableausoftware.com/v8.0/server/en-us/' $CSVOptionsHeader = 'Category,Option,Default Value,Description1,Description2,Link1,Link1Label,Link2,Link2Label' $CSVOptionsFormat = "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"" def init $fOpts = File.open("TTC_tabadminSetOptionsTv8.csv", 'w') $fOpts.puts $CSVOptionsHeader unless $fOpts.nil? end def cleanTxt txt return txt.gsub(/\\n/,' ').gsub(/"/,'""').strip end def pullCmds helpFile doc = Nokogiri::XML(open(helpFile)) cmdTable = doc.xpath('.//contents/body/div/table/tbody') cmdTable.each do |t| cmdRows = t.xpath('.//tr') cmdRows.each do |r| tds = r.xpath('.//td') option = tds[0].text.gsub(/\\n/,' ').strip category = option.split('.')[0] default = tds[1].text.gsub(/\\n/,' ').strip desc = tds[2].text.gsub(/\\n/,' ').strip desc1 = desc[0..250] desc2 = desc[251..501] links = tds[2].xpath('.//a') link1 = if links[0].nil? then '' else $Tv8HelpRoot + links[0].xpath('./@href').text.gsub(/\\n/,' ').strip end link2 = if links[1].nil? then '' else $Tv8HelpRoot + links[1].xpath('./@href').text.gsub(/\\n/,' ').strip end l1l = if links[0].nil? then '' else links[0].text end l2l = if links[1].nil? then '' else links[1].text end $fOpts.puts $CSVOptionsFormat % [category,option, default, desc1, desc2, link1, l1l, link2, l2l] end end end init pullCmds 'tabadmin set options cleaned.xml' #NOTE: the Tableau online help page has been saved locally as an XML file and cleaned up a bit $fOpts.close unless $fOpts.nil?

What TTC_TabadminHelpToDataTv8.rb does.

  • It accesses each row in the table as a separate set command option.
  • The first column contains the option's name.
  • The second column contains the option's default value.
  • The third column contains the option's description, which may exceed 255 charcters and contains zero, one, or two links, so the description is processed thus:
    • the description is split into two parts, each stored as its own field;
    • the links, if any, are captured as both a URL and label;
  • The fields are written into the CSV file.

How to use TTC_TabadminHelpToDataTv8.rb

  • Prerequisites
    • Minimal technical skills.
    • Have Ruby installed and ready to run.
    • Have the Nokogiri Ruby gem installed—it's used in the XML parsing.
    • Have the open-uri Ruby gem installed.
    • Have TTC_TabadminHelpToDataTv8.rb in place—it doesn't matter where, or what name you use, as long as you know where it is.
      You can copy the code above and paste it into your favourite text editor.
  • Running TTC_TabadminHelpToDataTv8.rb
    • Open a command prompt.
      (you can run it otherwise, but this is simple and straightforward)
    • CD to the directory containing the XML file you captured the online help page into.
    • Run it: "[path to]\ruby    [path to]\TTC_TabadminHelpToDataTv8.rb"
  • Presto. You now have a CSV file containing the tabadmin set command options as data.

The usual caveats.

TTC_TabadminHelpToDataTv8.rb works fine for me. But I wrote it and prepared the XML file it parses.

I hope it works for you, but make no guarantees. If you do use it and make improvements I hope that you'll post them back here as comments so I can learn from them, and hopefully other people can benefit from them too.

No comments:

Post a Comment