Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a txt file which contains fields A,B ,C. However, some of the txt files only contains fields B and C. I am using a wild card * load to load all txt files whether they have field A or not. If they have field A, I want them to load, else load as BLANK.
How do I write something like
IF (A, A, ' ') AS COLUMN_A
Thank you
Set NullAsValue Field1, Field2;
Have a look at the help.
You have to use a comma separated field list.
(I never tried it)
From the same discussion: Re: how to identify if a field is present in the load statement?
Loading with wildcards may present problems. For example, they don't take PRECEDING LOADs. If your file names follow a particular "file mask", you would better create a FOR EACH loop and load'n'process these files individually. All with a generic LOAD statement...
You also could
Set NullAsValue*;
then do your concatenations and then reset it
Set NullAsNull *;
----------------------------
Could also be that you have to do a dummy
LOAD * on the whole table for replacing the null()s
at the end of the process...
You can try the below code
Set ErrorMode = 0;
TEMP:
LOAD * INLINE [
T1, T2
A, 1
B, 2
C, 3
];
NoConcatenate
LOAD T1,T2,T3 Resident TEMP;
if $(ScriptError)=11 then
LOAD T1,T2 Resident TEMP;
ENDIF;
Set ErrorMode = 1;
Attached document for exception handling details.