Connecting to text files

When you open Tableau for the first time, you should see a screen similar to the one shown in the following screenshot. This image shows the various data sources available for analysis. Tableau provides you with two sample data sources, Sample - Coffee Chain (Access) and Sample - Superstore Sales (Excel), as shown in the following screenshot:

Connecting to text files

Getting ready

To prepare for the recipe, download and save titanic.txt from http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic.txt on your local hard drive. Remember this location, as we will use this file for this recipe. This file lists all the passengers (and their details) that boarded Titanic on its disastrous voyage.

Tip

Downloading the example code

You can download the example code files for all the Packt books you have purchased from your account at http://www.packtpub.com. If you have purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

How to do it...

Once you have downloaded the text file, perform the following steps to get the data in Tableau:

  1. Click on the Connect to data link to expand that area as shown in the following screenshot:
    How to do it...
  2. Click on Text File under the In a file section to launch the following screen:
    How to do it...
  3. Find and select titanic.txt in the given Open dialog box.
  4. As Tableau loads the data, it will prefill some of the options. For example, the field separator or delimiter and the header row. In this case, the field separator is a comma and the first row does have field names in it. So, hit OK on the dialog box as shown in the previous screenshot.
  5. Tableau provides three options to allow you to interact with the data, which is a text file in this recipe. These three options are shown in the following screenshot. By using the Connect live option, we can use the file connection as it is, and by using the Import all data or Import some data option, we can speed up the analysis by importing the data in Tableau's own format. In this case, let's just use the Connect Live option to load all 1,313 rows in the titanic.txt file.
    How to do it...
  6. As you can see, Tableau determined the data types and put some fields from the text file in the Dimensions section and others in Measures. Tableau determines data types of various fields using the Microsoft Jet Database Engine driver. Due to the driver's limitations, however, some fields are at times misinterpreted as measures when they should be detected as dimensions and vice versa. Since the field survived shows up as a Measures section, but contains a binary value of zero and one (no and yes), it would make sense to convert that field to a Dimensions section. To do so, simply drag the field over to the Dimensions section or right-click on the field and click on Convert to Dimension.

How it works…

We used a text file as a data source and connected to it using Tableau's data source connection options. Although most of the time Tableau can determine data types accurately, sometimes you need to pay attention to changing the data types to reflect the actual data type. In this case, we converted a binary field (containing zero and one) from the Measures field to the Dimensions field.

There's more...

In its online Knowledge Base, Tableau discusses how to handle situations where data types are misinterpreted because of Microsoft's Jet Database Engine's limitations. You can find that article at http://kb.tableausoftware.com/articles/knowledgebase/jet-incorrect-data-type-issues.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset