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 connecting Tableau to text file or csv, let us see the data present in the Text File. From the below screenshot, it’s just a standard text file with .csv extension. If you carefully observe, the First row has the Column names
If you haven’t started the Tableau yet, Double click on the desktop to open for connecting with text file. Once it is open, it looks like below screenshot
First, Under the Tableau Connect section, Please select the Text File Option
Once you chose the Text File Option, a new window will open to select the Text File from our file system. For now, we are selecting the Custmers.csv file
Once you have completed Connecting to Text File in Tableau, the below screenshot will appear. Please understand the following option before you start creating a report
- Customers are the connected default data source name (In fact, Text File name) assigned by 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 show File Path.
- Files: This section will display the number of Text Files we selected in the Tableau Text File source. In this example, we have selected only one file so, it is showing Customers.csv, but in real-time, you may work with more. We have the search bar under this section, and it is useful for a large number of files. For instance, If you have 20 or 30 files, 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, 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 text file tables using Joins.
Once you dragged the Customers file, Preview region will display the data present in that .csv file. After finishing the date review, click on Sheet 1 to design the Tableau Report
Oops, We forgot to tell you the most crucial property called Info.
Qualifiers will separate data present in every text file (does not matter with the extension name), and it may have column names as the first row. To configure these settings, Please select the Text file in the 4th region, and click on the Info button
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 set 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 a 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
Once you finished, click on the Sheet 1 tab to design the tableau report from a connected Text File.
- Data: This will display the list of currently connected data Sources. We have only one at this time. Otherwise, it shows 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
- It is the region where we design our Tableau reports by dragging Measures and Dimensions