In this article, we will show you how to connect Tableau to Text Files. Moreover how to use the data present in Text Files (such as .txt, .csv, .tab, .tsv) as Tableau Data Source with an example.
Steps involved in Connecting to Text File in Tableau
Before we start, Let us see the data present in the Text File. From the below screenshot, it’s just a normal text file with .csv extension. If you observe closely, the First row has the Column names
If you haven’t started the Tableau yet, Double click on the Tableau desktop to open. Once it is open, it looks like below screenshot
First, Under the Connect section, Please select the Text File Option
Once you selected the Text File Option, a new window will be opened to select the Text File from our file system. For now, we are selecting the Custmers.csv file as shown below
Once you are done, below screenshot will be appeared. Please understand the following option before you start creating a report
- Customers are the default data source name (In fact, Text File name) assigned by the Tableau. Please change this default name to a more meaningful unique name as per your requirements
- Directory: This section will display the Directory address of the selected Text File. In short, it will display File Path.
- Files: This section will display the number of Text Files we selected in the Text File source. In this example we selected only one file so, it is displaying Customers.csv but in real-time you may work with more. We have the search bar under this section and it is very useful for a large number of files. For instance, If you have 20 or 30 files then you can use this to search for a specific file name
- Drag Sheets Here: You have to Drag File(s) from Files to this Section. Tableau will only use the files present in this area. This is something like Dataset.
- This region will show the data present in our Dataset
We can add the text files to Region 4 in Multiple Ways: As the Name suggests, Either we can Drag the Customers.csv file from Region 3 to the 4th region or else simply double-click on the required file will automatically add
TIP: Tableau allows us to add multiple tables using Joins
Once you dragged the Customers file, Preview region will display the data present in that .csv file. Please refer below screenshot to understand the different areas. We will discuss the Connections part in another article.
Once you finished reviewing the data, Click on Sheet 1 to design the Tableau Report
Oops, We forgot to tell you the most important property called Info.
Data present in every text file (does not matter with the extension name) will be separated by Qualifiers and it may have column names as the first row. In order to configure these settings, Please select the Text file in the 4th region and click on the Info button as shown below
Once you click on Info button, a new drop-down window will open to configure the following items:
- Does the file includes field names in the First Row?: We have to specify whether the selected text file contains column names in the first row or not. By default, this option is selected as YES but changes as per your file requirements.
- Filed Separator: Please select the character that is used to separate the columns in the text file. If the character is not present in the list, select Other and type a custom character.
- Text Qualifier: Please specify the text qualifier used to encloses values in our selected Text File.
- Character Set: Please select the character set that describes the text file encoding. Mostly Tableau will detect it for you. If not, Please change it manually.
- Locale: Language used to parse the Text File. Tableau will use this to separate the numbers etc
Once you are finished, click on the Sheet 1 tab to design the report.
- Data: This will display the list of currently connected data Sources. We have only one at this time. Otherwise, it will display all the data sources available.
- Dimensions: You can place the columns with string data under the Dimensions section
- Measures: You can place columns with Numeric data or Metric values under the Measures section
- This is the region where we design our Tableau reports by dragging Measures and Dimensions