Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Like this:
For Each vFile in FileList('lib://CSV/csv_*.csv')
Let vSize = Alt(FileSize(vFile), 0);
If vSize > 1024 Then
... load from $(vFile)
End If
Next VFile
Dear Jonathan,
Thanks for ur reply.
when i try this
For Each vFile in FileList('lib://CSV/csv_*.csv')
Let vSize = Alt(FileSize(vFile), 0);
If vSize > 1024 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
no records are loaded
Dear Jonathan,
PFA for app.
!Dear Jonathan,
PFA for sample data.
I have two csv file
csv_20180801.csv (file size 1kb)
csv_20180902.csv (file size 0kb)
I want to load only
csv_20180801.csv
!Dear Jonathan,
PFA for sample data.
I have two csv file
csv_20180801.csv (file size 1kb)
csv_20180902.csv (file size 0kb)
I want to load only
csv_20180801.csv
Well the sample will only load files with a size greater than 1024 bytes because
>> I'd like to set up a parameter of: if the file >= 1KB, load, if not, skip.
But csv_20180801.csv is only 400 bytes, so based on your original post, it should not be loaded.
Dear Jonathan,
Actually i have some other files of size 13kb,9kb like still its also not loading.
Regards,
Joshua.
I suggest that you post the script you are trying so that we can see where you went wrong.