Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to concatenate 2 tables with the same column names and compute new columns from existing columns. If I do this:
Sector0:
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date],
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm]
FROM
<file>
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
Concatenate(Sector0)
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date],
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm]
FROM
<file2>
(biff, embedded labels, table is Sheet1$);
there will be the error messages "Field not found - <Time>" and "Table not found Concatenate(Sector0)...".
But if the code is like the one below, the script can successfully load.
Sector0:
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date]
FROM
<file>
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
Concatenate(Sector0)
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date],
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm]
FROM
<file2>
(biff, embedded labels, table is Sheet1$);
Thanks.
Rachel
Hi,
In First table do you have column named Time in the table? If there is no Time column then you will get this error.
Regards,
Jagan.
Yes, I created a Time column in the first table Sector0
Sector0:
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time
Hi,
The error is because of this two lines
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm]
In that Time is used as a Column, it should be like this
Sector0:
LOAD
*,
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm];
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date]
FROM
<file>
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
Regards,
Jagan.
Ok. But i have another column to add and if I put this, it does not work.
There is this error message "Field not found - <Before 10am>
LOAD
*,
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm],
If([Before 10am]+[After 10pm]>0,'Night Shift','Day Shift') as Shift;
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date]
FROM
<file>
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
add another load (below, not bold)
load
*,
If([Before 10am]+[After 10pm]>0,'Night Shift','Day Shift') as Shift;
LOAD
*,
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm]
// If([Before 10am]+[After 10pm]>0,'Night Shift','Day Shift') as Shift;
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date]
FROM
<file>
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
to sum it up, you can't use a field name in the same load where it is created (as well as e.g. in it's where clause).
Use preceding loads in these cases.
Hi,
In the top load statement you dont have [Before 10am] and [After 10pm] columns, that is why you are getting the errrors.
Try this
LOAD
*,
If([Before 10am]+[After 10pm]>0,'Night Shift','Day Shift') as Shift;
LOAD
*,
If(time#([Time],'hh:mm:ss')<time#('10:00:00','hh:mm:ss'),1,0) as [Before 10am],
If(time#([Time],'hh:mm:ss')>time#('22:00:00','hh:mm:ss'),1,0) as [After 10pm];
LOAD *,
Time([Date Confirmed],'hh:mm:ss') as Time,
Date([Date Confirmed],'M/D/YYYY') as [Actual Date]
FROM
<file>
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
Regards,
Jagan.