Topic: Split Function in Kusto Query (KQL) How to split string into values in Kusto Query Language
In this
article, we are going to learn about Split function in Kusto Query Language,
Splits a given string according to a given delimiter and returns a string array
with the contained substrings, optionally, a specific substring can be returned
if exists. Kusto Query Language is a powerful tool for exploring your data and discovering patterns, identifying anomalies and outliers, creating statistical modeling, etc.
//split
// Splits a given string according to a given delimiter and returns a string array with the contained substrings.
//Optionally, a specific substring can be returned if exists.
//Let's create a table Customer
//.drop table Customer
.create table Customer (CustomerId: long, FName: string,LName:string,FileLocation:string )
.ingest inline into table Customer <|
1,Aamir,Shahzad,C:\Documents\Newsletters\Summer2018.pdf
2,Raza,ALI,D:\Documents\MyTestFileLocation\Tax_2019.pdf
3,Lisa,
4,steve,Ladson
5,Robert,Jr
,aamir,ali
// split the values into an Array
Customer
| extend split(FileLocation,'\\')
// Let's divide the results into sub arrays
Customer
| extend DriveName=split(FileLocation,'\\',0), MainFolder=split(FileLocation,'\\',1),Subfolder=split(FileLocation,'\\',2),FileName=split(FileLocation,'\\',3)
//Let's get the value from the arrary and print in nice readable way
Customer
| extend MyArrary=split(FileLocation,'\\')
| extend DriveName=MyArrary[0],Mainfolder=MyArrary[1],SubFolder=MyArrary[2],FileName=MyArrary[3]
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.