Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a huge list of entries in excel for example
MatchKey Category
*qwerty* critical
*asdfg* medium
*organic* high
*metal* low
*sql* medium
I need to match the matchkey with the available list of hostnames.
for example if my hostname is
Hostname
qwertykeyboard
asdfgcfghkodddgdfgfg
metalicboard
sqlquery
organicapple
my output should be like if i select any hostname the category should be reflected
if I select qwertykeyboard the Cateogry critical should be reflecting.
Thanks in advance
May be like below:
Map_Table:
Mapping Load * Inline [
Matchkey, Category
*qwerty*, critical
*asdfgc*, medium
*organi*, high
*metali*, low
*sqlque*, medium
];
Host_Table:
Load * Inline [
Hostname
qwertykeyboard
asdfgcfghkodddgdfgfg
metalicboard
sqlquery
organicapple
];
NoConcatenate
Final_Table:
Load
Hostname,
ApplyMap('Map_Table','*'&Mid(Hostname,1,6)&'*') as Category
Resident Host_Table;
Drop table Host_Table;
Note: Please note that I restricted the MatchKey field to length of 6 characters to get this working..
Hope this helps...
I assume you also want to find matches in the mid or end of a Hostname, and I also assume that you only want to map a single category, i.e. there are no multiple categories to match (which is possible with a different script).
MAP:
Mapping Load
PurgeChar(Matchkey,'*') as Matchkey, '\/'&Category&'/\' as Category Inline [
Matchkey, Category
*qwerty, critical
*asdfgc*, medium
*organi*, high
*metali*, low
*sqlque*, medium
];
Host_Table:
Load * Inline [
Hostname
qwertykeyboard
asdfgcfghkodddgdfgfg
metalicboard
sqlquery
organicapple
];
NoConcatenate
Final_Table:
Load
Hostname,
Textbetween(MapSubString('MAP',Hostname),'\/','/\') as Category
Resident Host_Table
;
Drop table Host_Table;
This is not work Thirumala, I want to show for the selected hostname which is the matching category.
If I select metaliboard, category low should be displayed
This is not working.
For selected hostname I need respective category.
One more way
Data:
LOAD HostName,
pick( wildmatch(lower(HostName),'*qwerty*','*asdfg*','*organic*','*metal*','*sql*'),
'critical','medium','high','low','medium') as Category
FROM Table
Thanks for the solution, But I have wildcard search around 3000 to match with Hostname.
Will this work then?
If you create a list box and select a hostname it will show you the category. I created a list box and when I selected Metalicboard it is displaying 'Low' as the category. Please see the attached file:
Hi Thirumala,
You have fixed the length to 6 in Mid() function but my match list have variable length, which is not giving me the accurate result.
// list out 3000 Match key
Data:
LOAD *, RowNo() as Row inline [
MatchKey, Category
qwerty, critical
asdfg, medium
organic, high
metal, low
sql, medium ];
New:
lOAD
concat( chr(39) &'*'& lower(MatchKey) &'*'& chr(39),',',Row ) as MatchKey,
concat( chr(39) & lower(Category) & chr(39),',',Row ) as Category
Resident Data;
DROP Table Data;
let vMatchKey = peek('MatchKey',0,'New');
let vCategory = peek('Category',0,'New');
Data:
LOAD HostName,
pick(wildmatch(lower(HostName),$(vMatchKey)),$(vCategory)) as Category
FROM Table;
drop table New;