6 Replies Latest reply on Oct 24, 2018 10:12 AM by Dan Vrabie

    Tableau Prep - generate headers from file

    Dan Vrabie

      Hi,

       

      I'm brand new to Tableau Prep, and I'm trying to automate some data flows.

       

      The issue that I'm having is that I need to union multiple data files (txt) that have no header. I can import all of them through the Multiple File option, but I end up with a generic header (F1, F2, F3 ...). I can manually rename the header,s but there are lots of fields and it is annoying.

       

      Is there a way I can import a file (txt, xls etc) that contains the header, and through Tableau Prep functionality:

      - union this header file with the rest of the data files AND

      - make the header line in the hear file the new header for the combined file?

       

      This would automate my process and also make it scaleable.

       

      Thank you.

        • 1. Re: Tableau Prep - generate headers from file
          Rory Wallis

          Hi Dan,

           

          I could be wrong but I'm not sure that's possible. Why is it that the data coming into the Flow does not already have a header?

           

          Rory

          • 2. Re: Tableau Prep - generate headers from file
            Dan Vrabie

            Hi Rory,

             

            Thank you for your reply. I kind of figured out it's not possible, at least not with the current functionality.

             

            My options are:

            1. run a command prompt line that concatenates the files, with the file header at the top, and then import the consolidated file and indicate the header line as the first line

            2. combine all files first in Tableau Prep with the "multiple files" option and a "generic" header (F1,F2,F3...), and then add a step in Tableau Prep where I manually type the header for the combined file.

             

            I've opted for the second solution.

             

            Relative to your question, the system that dumps the file does not generate a file header in the text format; i can do it as an xml, but then reading the xml files might generate some issues.

             

            Thanks.

             

            dan

            • 3. Re: Tableau Prep - generate headers from file
              Rory Wallis

              Yeah I would have gone with option 2 as well. If it's automating adding the headers in Prep then anything to do with the missing headers before this becomes moot.

              • 4. Re: Tableau Prep - generate headers from file
                George Brooks

                You may be able to use tableau prep for option one.  If all of the columns in all of the data files are the same.  Use Tableau Prep to do the concatenation and then output the file to use used a new input.

                • 5. Re: Tableau Prep - generate headers from file
                  Don Wise

                  Hi Dan,

                  Yes, this is possible with a little initial work in Tableau Prep for your first option. It won't be automatically joined unfortunately.  Please see below screenshots with some mocked up data.  And this help file in Tableau Prep (about middle section): Join or Union Data - Tableau Fixing Mis-Matched Fields.  If this resolves your question, please mark this response as correct. Thx! Don

                   

                  Here's an Excel file w/Header only:

                  Screen Shot 2018-10-24 at 9.39.53 AM.png

                  Here's the Excel file w/No Header:

                  Screen Shot 2018-10-24 at 9.39.14 AM.png

                  Bring both files into Tableau Prep:

                  Screen Shot 2018-10-24 at 9.40.32 AM.png

                  Then perform a UNION, not a JOIN, by dragging one on top of the other:

                  Screen Shot 2018-10-24 at 9.41.52 AM.png

                  In the left side pane you'll notice that the fields are mis-matched. Color-coded by Excel sheet inputs:

                  Screen Shot 2018-10-24 at 9.42.10 AM.png

                  To globally fix the mis-matched fields, place your cursor on each field to select the two fields that match, then right-click and "MERGE".  Do that for each field until done:

                  Screen Shot 2018-10-24 at 9.54.45 AM.png.

                  When done, you'll have a view that looks like this:

                  Screen Shot 2018-10-24 at 9.55.02 AM.png

                  Finally, select an output step:

                  Screen Shot 2018-10-24 at 9.55.20 AM.png

                  1 of 1 people found this helpful
                  • 6. Re: Tableau Prep - generate headers from file
                    Dan Vrabie

                    Thank you for the suggestions! While not a direct route, I was able to make it work!