Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In CSV one colum is unavailable in some times,
is it possible to add if condition in script to load data of that colum when it's available in CSV . i use below syntax but doesn't work
if(len([ID])=0,' ',[ID]) as [ID],
try to use the statement..
Load * from source.csv;
No, i want to have column names
It's not possible to check if a field is available from inside of a load-statement. You will always need to have additionally steps to check from outside for example with a filelist-loop, like here: Re: Import files one at a time, check for fields, and overwrite existing files or you need a forced concatenation like this one:
YourTable:
Load '' as ID autogenerate 0;
concatenate(YourTable)
Load * From YourCSV.csv;
- Marcus
Try the below one,
Temp:
Noconcatenate First 1 LOAD *
FROM
[Test.xlsx]
(ooxml, embedded labels, table is Sheet1);
If FieldNumber('Field3','Temp') > 0 Then
LET vField = 'Field3';
Else
LET vField = Chr(39)&Chr(39);
End if
Drop Table Temp;
LOAD
Field1,
Field2,
$(vField) as F3
from Test.xlsx]
(ooxml, embedded labels, table is Sheet1);