Forum Discussion
stephchnva
1 year agoFrequent Visitor
How do I extract the 17-alphanumeric characters in a column, delimiter
Hello guys, I need help. How do I extract the 17-alphanumeric characters in the "name" column. I've tried different ways of extracting by delimiter but it's just not working. Name 24/1...
- 1 year ago
Download example PBIX file with the code below
= try List.Select(Text.Split([Name], " / "), each Text.Length(_) = 17){0} otherwise nullRegards
Phil
ThxAlot
1 year agoSuper User
For simplicity and accuracy, incorporate regular express by python script,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NYzLCsIwEEV/ZchaSGYS02ZZLCpFV4JoQxehBhJoUvGFn2+guL3nnGstI8VRcBKkgAPud5tjTVrKBkmqtS5bM/kvdHPIzzkDG1aWnbd4ufamNwdRlKo2xRKaI/5vOpeih1OKr7AUJKD1IxQsC27dJ94WgJWb7sHld/KPOEJObBh+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
#"Added pq" = Table.AddColumn(Source, "pq", each List.Select(Text.Split([Name], " / "), each Text.Length(_) = 17 and not Text.Contains(_, " ")){0}?),
#"Run Python script" = Python.Execute("df['py re'] = df['Name'].str.findall(r'\w{17}').apply(lambda match: match[0] if len(match)>0 else '')",[df=#"Added pq"]),
Result = #"Run Python script"{[Name="df"]}[Value]
in
Result