Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have data like this. how can i add headers for first four columns where the header is not available
PFA
Hi,
one possibility to partially rename headers could be:
tabHeaders:
LOAD * INLINE [
Col, Header
@1, Header1
@2, Header2
@3, Header3
@4, Header4
];
tabTemp:
CrossTable(Col, Header)
LOAD 1, *
FROM [http://community.qlik.com/servlet/JiveServlet/download/695530-145115/Revised_Test.txt] (txt, codepage is 1252, no labels, delimiter is '\t', msq)
Where RecNo()=1;
Concatenate(tabHeaders)
LOAD Col, Header
Resident tabTemp
Where Len(Header);
mapHeaders:
Mapping LOAD * Resident tabHeaders;
DROP Tables tabTemp, tabHeaders;
tabInput:
LOAD *
FROM [http://community.qlik.com/servlet/JiveServlet/download/695530-145115/Revised_Test.txt] (txt, codepage is 1252, no labels, delimiter is '\t', msq)
Where RecNo()>1;
RENAME Fields using mapHeaders;
hope this helps
regards
Marco
Hi,
When you load table using "Table Files" then in the preview of data you can give header name ..
HTH
Sushil
LOAD @1 as test,
@2,
@3,
@4,
@5,
@6,
@7,
@8,
@9,
@10,
@11,
@12,
@13,
@14,
@15,
@16
FROM
C:\Users\G96893\Downloads\Revised_Test.txt
(txt, codepage is 1252, explicit labels, delimiter is '\t', msq);
you can name all columns as desired by using as
Hi Sushil,
Tq for your response, but that one is manual thing to be done for every file.
Is there any alternative way?
Hi,
Try this code
Directory;
LOAD [2014 Outlook],
Source,
S530800,
FE400,
Jan,
Feb,
Mar,
Apr,
May,
Jun,
Jul,
Aug,
Sep,
Oct,
Nov,
Dec
FROM
[..\..\Downloads\Revised_Test.txt]
(txt, codepage is 1252, embedded labels, delimiter is '\t', msq, filters(
Replace(1, bottom, StrCnd(null, case)),
Replace(2, bottom, StrCnd(null, not)),
Replace(2, bottom, StrCnd(null, not)),
Replace(2, bottom, StrCnd(null, not)),
Replace(2, bottom, StrCnd(null, case)),
Replace(3, bottom, StrCnd(null, case)),
Replace(4, bottom, StrCnd(null, case))
));
LOAD @1 as Test1,
@2 as Test2,
@3 as Test3,
@4 as Test4,
@5 as Test45,
@6 as Test6,
@7 as Test7
FROM file
and in transformation tab delete first row. So that you can not give first row of data that is (jan,feb,mar)
Its one time task at the time of script writing.
Hi,
one possibility to partially rename headers could be:
tabHeaders:
LOAD * INLINE [
Col, Header
@1, Header1
@2, Header2
@3, Header3
@4, Header4
];
tabTemp:
CrossTable(Col, Header)
LOAD 1, *
FROM [http://community.qlik.com/servlet/JiveServlet/download/695530-145115/Revised_Test.txt] (txt, codepage is 1252, no labels, delimiter is '\t', msq)
Where RecNo()=1;
Concatenate(tabHeaders)
LOAD Col, Header
Resident tabTemp
Where Len(Header);
mapHeaders:
Mapping LOAD * Resident tabHeaders;
DROP Tables tabTemp, tabHeaders;
tabInput:
LOAD *
FROM [http://community.qlik.com/servlet/JiveServlet/download/695530-145115/Revised_Test.txt] (txt, codepage is 1252, no labels, delimiter is '\t', msq)
Where RecNo()>1;
RENAME Fields using mapHeaders;
hope this helps
regards
Marco
Excellent work Marco...tq a lot