Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How can I use FileSize() to check if the file is there but blank (i.e. 0 bytes)?
I already use LET vFileExists = NOT ISNULL(FileSize('$(vFileName)')); to see if a file is there, but I don't believe it checks for the actual size.
This is not working:
DO
CENTRAL_LINE:
LOAD FIN,
MRN,
UNIT,
INSERT_DT,
date(MonthName(left(INSERT_DT,10)),'MM-YY') as TRX_DATE_CL,
// date#(INSERT_DT,'MM/DD/YYYY') as TRX_DATE_CL,
time(INSERT_DT) as TRX_TIME_CL,
LINE_LABEL,
DOC_PRSNL,
DOC_DT_TM,
DOC_ACTVITY,
DOC_VALUE,
trim( SubField( trim(DOC_VALUE),',')) as DOC_VALUE_CLEAN,
HIGH_DAY_CNT,
CUR_DAY_CNT,
ADMIT_DT,
DISCHG_DT,
SITE,
TYPE,
REMOVE_DT,
DNR_FLG,
DOCUMENT_LOC,
ENCNTR_TYPE,
PROV_POSITION,
PROV_ENCNTR_RELTN,
FACILITY as FACILITY_CL,
LINE_LABEL_ID
FROM
[..\External_Data\1dho_uxp_cent_line_eval*.csv]
//FROM [$(vCLFile)] (txt, codepage is 1252, embedded labels, delimiter is ',', msq)
(txt, codepage is 1252, embedded labels, delimiter is ',', msq)
where HIGH_DAY_CNT = CUR_DAY_CNT and CUR_DAY_CNT > 0;
loop while FileSize('..\External_Data\1dho_uxp_cent_line_eval*.csv')>0;
store CENTRAL_LINE into ..\QVD\01_Extract_QVD\CENTRAL_LINE.qvd (qvd);
SET vFileName='C:\Users\Sheet.txt';
Let vFileExsist=if(FileSize($(vFileName))>0,-1,0);
if $(vFileExsist) then
Table1:
load * from $(vFileName)
(ooxml,no labels,table is[]);
Else
Load
MsgBox('File Not Found') as Warning1;
End if;
Thanks but it is still trying to load the files that are 0 bytes.
Maybe like this:
SET vFileName='C:\Users\admin\Desktop\TABLE.txt';
Let vFileExsist= if(FileSize('$(vFileName)')>0,1,0);
if $(vFileExsist) = 1 then
Table1:
load * from $(vFileName)
(txt, utf8, embedded labels, delimiter is ',', msq);
else
Load MsgBox ('File with 0KB')
autogenerate 1;
End if;
May be the file size is not exactly zero bytes. Try LOAD *, FileSize( ) as X from file name; and try finding the exact size of the file.
A CSV file that is truely empty will be 0 bytes, but it is possible you have files that have a header row but not records. You could use filesize() to test that the number of characters is more than the length of the header row.
Your logic is wrong. Use this pattern instead:
For Each vFile in FileList('..\External_Data\1dho_uxp_cent_line_eval*.csv')
If FileSize(vFile) > 50 Then
CENTRAL_LINE:
LOAD FIN,
MRN,
UNIT,
...
FROM [$(vFile)]
(txt, codepage is 1252, embedded labels, delimiter is ',', msq)
Where ...
End If
Next
Cassandra, did any of the posters recommendations help you resolve things? If so, please be sure to click the Accept as Solution on those that did. If you did something else, if you can share that solution, others may be able to learn from your experience as well, and you can then use the button to mark that as the solution as well, so folks will know that is what you did...
Regards,
Brett