Guiseppe,

You can only call GetDirectoryListing() on a directory.  This will
return an entire listing.  You can then filter the results based on
whatever you want, but there is no built-in function.  I've written a
function called FilterDir that appears in the launcher.pbl script
though, and it relies on some additional customfunctions to do the
filtering.


Here, inlist is what gets returned from GetDirectoryListing(), path a
pathlist you want to prepend onto the file name, which can be convenient
if you want to access this later. type is a text string that specifies
which type of filter to use--this isn't exactly wildcarding, but if you
only have .csv files, it would be easy to adapt IsDataFile() and just
cut the other code paths out.  It also separates and return the
directories, which you may not want and you should be able to cut that
out as well.

##This is a hard-coded filter;
##it will only return .pbl files and directories.
define FilterDir(inlist,pathhead,type)
{

  tmpdir <- []
  tmppbl <- []
  loop(i, inlist)
  {

    if(IsDirectory(pathhead+i))
      {
         tmpdir <- Append(tmpdir,i)
      }else{
          
       if(type=="*.pbl")
       {
       if(IsPEBLFile(i))
        {
            tmppbl <- Append(tmppbl,i)
        }
       } elseif(type=="data files") {
         if(IsDataFile(i))
         {
             tmppbl <- Append(tmppbl,i)
         }
                
      }elseif(type=="*.*"){
           ##no filter:
           tmppbl <- Append(tmppbl,i)

       }
     }
  }
  return [Sort(tmpdir),Sort(tmppbl)]

}




define IsDataFile(fname)
{

  returnval <- 0
  len <- StringLength(fname)    
  if(len>4)     
           {
            tmp <- SubString(fname,len-3,len)
            if(tmp==".csv") 
                {
                  returnval <-  1
                }

          }
   return returnval
}






On Mon, 2015-11-09 at 11:04 +0100, Giuseppe Cabras wrote:
> Dear Shane,
> in my pebl script I would like to use the function GetDirectoryListing 
> ("../../DATA/*.csv")
> but wildcard symbol does not work, I get the error:
> Unable to get Directory listing at ../../DATA/*.csvknown error
> Any suggestion on how to solve this problem?
> Cheers,
> 
> ------------------------------------------------------------------------------
> Presto, an open source distributed SQL query engine for big data, initially
> developed by Facebook, enables you to easily query your data on Hadoop in a 
> more interactive manner. Teradata is also now providing full enterprise
> support for Presto. Download a free open source copy now.
> http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
> _______________________________________________
> Pebl-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pebl-list



------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Pebl-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pebl-list

Reply via email to