6 Replies Latest reply: Jun 3, 2011 11:12 AM by Richard DeRocco RSS

    Peek function

    Logesh Jayaraman

      Hi ,

       

      Is it possible to use the peek function with variable. Need to dynamically specify the column position(Row number which the data has to be picked)

      For e.g

       

      i can define in loop like this

       

      let e=1

       

      do while e<=10

       

      let c=  peek('column',$(e),'Table' )

       

      let e=e+1;

       

      loop

        • Re: Peek function
          Deepak Kurup

          hi XXX,

           

          Yes its possible. but you need to add e variable to c. Hence you will have multiple variable.

           

           

          PFA.

           

           

          Deepak

            • Peek function
              Logesh Jayaraman

              Thanks for your response Deepak.

              It is fine for the first value not for the second value.It is not storing the next value .

               

                Is there any way i can store like this

               

                 Let vRecord= Load id Resident table; 

               

              Please find my scrip i have used

               

               

              Tabledata:

              LOAD id,

              [Table],

              Filelocation

              FROM

              [C:\Documents and Settings\Tablelist.xls]

              (biff, embedded labels, table is Sheet1$);

               

              Tabledetails:

              LOAD max(id)  as maxid

              FROM

              [C:\Documents and Settings\\Tablelist.xls]

              (biff, embedded labels, table is Sheet1$);

               

              Let x=Peek('maxid' ,0,'Tabledetails');

              Let a=1;

               

              Do while a<=x

              flocation:

              Load  Filelocation  Resident Tabledata where id=$(a);

              Let filocation= Peek('Filelocation' ,0,'flocation');

              Finaltable:  

              LOAD  *  FROM $(filocation);

              let a=a+1;

              loop

               

               

              File location when a =1 it is fine .But for a=2 it is null. So the second row data is not getting loaded.  Please suggest

               

               

               

              • Re: Peek function
                Logesh Jayaraman

                Thanks for your response Deepak.

                It is fine for the first value not for the second value.It is not storing the next value .

                 

                  Is there any way i can store like this

                 

                   Let vRecord= Load id Resident table; 

                 

                Please find my scrip i have used

                 

                 

                Tabledata:

                LOAD id,

                [Table],

                Filelocation

                FROM

                [C:\Documents and Settings\Tablelist.xls]

                (biff, embedded labels, table is Sheet1$);

                 

                Tabledetails:

                LOAD max(id)  as maxid

                FROM

                [C:\Documents and Settings\\Tablelist.xls]

                (biff, embedded labels, table is Sheet1$);

                 

                Let x=Peek('maxid' ,0,'Tabledetails');

                Let a=1;

                 

                Do while a<=x

                flocation:

                Load  Filelocation  Resident Tabledata where id=$(a);

                Let filocation= Peek('Filelocation' ,0,'flocation');

                Finaltable:  

                LOAD  *  FROM $(filocation);

                let a=a+1;

                loop

                 

                 

                File location when a =1 it is fine .But for a=2 it is null. So the second row data is not getting loaded.  Please suggest

                 

                 

                 

                  • Re: Peek function
                    Deepak Kurup

                    hi,

                     

                    Because u need to create array of variable like below

                     

                    fillocation$(a) = peek('FileLocation',$(a),flocation)

                      • Peek function

                        I do something similar to this with for loops.  Not sure exactly how much this relates to what you want to do but here's an idea:

                         

                        Tables:

                        FIRST 1 LOAD DISTINCT

                             filename() as 'File',

                             QVDNoOfFields('$(vPath)' & filename()) as 'Field Count'

                        FROM

                        [C:\Documents and Settings\My Documents\QV\*.qvd]

                        (qvd);

                         

                         

                        For i = 1 to NoOfRows('Tables')

                         

                        LET vFileName = peek('File',$(i)-1,'Tables');

                        LET vFieldCount=peek('Field Count',$(i)-1,'Tables');

                         

                        QVDs:

                        FIRST 1 LOAD DISTINCT

                             filename() as 'qvd',

                             filetime() as 'qvd Time',

                             date(left(filetime(),index(filetime(),' ')-1)) as 'qvd Date',

                             qvdNoOfFields('$(vPath)' & filename()) as 'qvd Number of Fields',

                             evaluate(filesize('$(vPath)$(vFileName)')/1048576) as 'qvd File Size (mb)',

                             QvdNoOfRecords('$(vPath)$(vFileName)') as 'qvd No of Records'

                        FROM

                        $(vPath)$(vFileName)

                        (qvd);

                         

                        Next