8 Replies Latest reply: Sep 21, 2018 6:52 AM by Jonathan Dienst RSS

    Loading based on file size

    Joshua Solomon

      Dear all,

       

      I am trying to load a set of CSV files that we receive every night, however we receive empty 'shells' if no new data has been entered in the system. So what happens is we have 1KB files sitting on the server being ran and causing an error during the load. Other than setting the error mode to zero, I'd like to set up a parameter of: if the file >= 1KB, load, if not, skip.



      I tried this script

       

      LET vSize = filesize('lib://CSV/csv_*.csv');


      if not IsNull(vSize) then

       

       

      File:

      Load

          book_no,

          receipt_no,

          loan_no,

          cust_name,

          custid,

          cust_branch_code,

          cust_branch_name,

          re_code,

          re_branch_code,

          receipt_date,

          emi,

          "total",

          pay_mode,

          chqno,

          chq_date,

          cancelled,

          cancel_reason,

          FileSize() as filesize,

          cancelled_date

      FROM [lib://CSV/csv_*.csv]

      (txt, codepage is 28591, embedded labels, delimiter is ',', msq)

      where len(cancelled_date)=0

      ;

      end if

      STORE File INTO 'lib://QVdata/Transactions.qvd' (qvd); 

      drop table File;

      exit script;

       

       

      Regards,

      Joshua.