7 Replies Latest reply: Jan 22, 2015 1:16 AM by sruti k RSS

    adding expilcit headers

    sruti k


      Hi All,

       

         I have data like this. how can i add headers for first four columns where the header is not available

         PFA

        • Re: adding expilcit headers
          Sushil Kumar

          Hi,

           

          When you load table using "Table Files" then in the preview of data you can give header name ..

           

          HTH

          Sushil

            • Re: adding expilcit headers
              sruti k

              Hi Sushil,

               

              Tq for your response, but that one is manual thing to be done for every file.

                Is there any alternative way?

                • Re: adding expilcit headers
                  Sushil Kumar

                  Hi,

                   

                  Try this code

                   

                   

                  Directory;
                  LOAD [2014 Outlook],
                  Source,
                  S530800,
                  FE400,
                  Jan,
                  Feb,
                  Mar,
                  Apr,
                  May,
                  Jun,
                  Jul,
                  Aug,
                  Sep,
                  Oct,
                  Nov,
                  Dec
                  FROM
                  [..\..\Downloads\Revised_Test.txt]
                  (
                  txt, codepage is 1252, embedded labels, delimiter is '\t', msq, filters(
                  Replace(1, bottom, StrCnd(null, case)),
                  Replace(2, bottom, StrCnd(null, not)),
                  Replace(2, bottom, StrCnd(null, not)),
                  Replace(2, bottom, StrCnd(null, not)),
                  Replace(2, bottom, StrCnd(null, case)),
                  Replace(3, bottom, StrCnd(null, case)),
                  Replace(4, bottom, StrCnd(null, case))
                  ));

              • Re: adding expilcit headers
                ioannis giakoumakis

                LOAD @1 as test,

                     @2,

                     @3,

                     @4,

                     @5,

                     @6,

                     @7,

                     @8,

                     @9,

                     @10,

                     @11,

                     @12,

                     @13,

                     @14,

                     @15,

                     @16

                FROM

                C:\Users\G96893\Downloads\Revised_Test.txt

                (txt, codepage is 1252, explicit labels, delimiter is '\t', msq);

                 

                you can name all columns as desired by using as

                • Re: adding expilcit headers
                  balkumar chandel

                  LOAD @1 as Test1,

                       @2 as Test2,

                       @3 as Test3,

                       @4 as Test4,

                       @5 as Test45,

                       @6 as Test6,

                       @7 as Test7

                  FROM file

                   

                  and in transformation tab delete first row. So that you can not give first row of data that is (jan,feb,mar)

                  Its one time task at the time of script writing.

                  • Re: adding expilcit headers
                    Marco Wedel

                    Hi,

                     

                    one possibility to partially rename headers could be:

                     

                    QlikCommunity_Thread_148519_Pic1.JPG

                     

                    tabHeaders:
                    LOAD * INLINE [
                        Col, Header
                        @1, Header1
                        @2, Header2
                        @3, Header3
                        @4, Header4
                    ];
                    
                    tabTemp:
                    CrossTable(Col, Header)
                    LOAD 1, *
                    FROM [http://community.qlik.com/servlet/JiveServlet/download/695530-145115/Revised_Test.txt] (txt, codepage is 1252, no labels, delimiter is '\t', msq)
                    Where RecNo()=1;
                    
                    Concatenate(tabHeaders)
                    LOAD Col, Header
                    Resident tabTemp
                    Where Len(Header);
                    
                    mapHeaders:
                    Mapping LOAD * Resident tabHeaders;
                    
                    DROP Tables tabTemp, tabHeaders;
                    
                    tabInput:
                    LOAD *
                    FROM [http://community.qlik.com/servlet/JiveServlet/download/695530-145115/Revised_Test.txt] (txt, codepage is 1252, no labels, delimiter is '\t', msq)
                    Where RecNo()>1;
                    
                    RENAME Fields using mapHeaders;
                    

                     

                    hope this helps

                     

                    regards

                     

                    Marco