Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi I am getting some data in flat file in the given format and i want to load these data in a tabular format with two columns Say used % and Description
if the usage % is 100 then there will not be any other line but if its lesser then it will show the components which are not being used .
so i want to capture the usage % in used % colum and component in description
I would be getting the flat file with data in below format .. the text in bold will remain same but the values like 98% or ABC , XYZ may change . component not used will be listed below the second bold line . if the usage is 100 as in SAMPLE2.txt then the below line will not be there .
Usage = 98%
The following components are not used
ABC
XYZ
Hi,
Try this script
Data:
LOAD DISTINCT *;
LOAD
If(WildMatch(@1, 'Usage*'), Trim(SubField(@1, '=', 2))) AS Usage,
FileName() AS FileName
FROM
(txt, codepage is 1252, no labels, delimiter is '\t', msq)
WHERE WildMatch(@1, 'Usage*');
LEFT JOIN(Data)
LOAD
If(NOT WildMatch(@1, 'Usage*', 'The following components*'), @1) AS Component,
FileName() AS FileName
FROM
(txt, codepage is 1252, no labels, delimiter is '\t', msq)
WHERE NOT WildMatch(@1, 'Usage*', 'The following components*');