Forum Discussion
Read a list of Node Name and its software name, then find the next Node Name
I know that feature, but since my dataset is on a one long column without any separated commas, how can I set it into cols and rows per Node Name is the question.
- SergeiBaklanApr 19, 2021Diamond Contributor
How do we know that the text in one row is node name and in another one is software name? Perhaps you may share small sample file to illustrate.
- TB_VNApr 23, 2021Copper ContributorThe text will say "Node Name: Server1"...etc, same goes for Software Name: nameofsw in front it. These are probably the keywords you're after?
- SergeiBaklanApr 24, 2021Diamond Contributor
Yes, that's more clear now, thank you.
I'd use Power Query for such transformation. Source could be CSV file as in your tag, in my sample that's the column named "range". In brief: query it, create another column with node names against each record, group by nodes without aggregation creating list of software for each node, create table from these lists.
It looks like
and M-script is
let Source = Excel.CurrentWorkbook(){[Name="range"]}[Content], #"Filtered Rows" = Table.SelectRows(Source, each ([Column1] <> null)), #"Added Custom" = Table.AddColumn( #"Filtered Rows", "Nodes", each if Text.Start([Column1],9)="NodeName:" then [Column1] else null ), #"Filled Down" = Table.FillDown(#"Added Custom",{"Nodes"}), #"Filtered Rows1" = Table.SelectRows(#"Filled Down", each not Text.Contains([Column1], "NodeName:")), #"Replaced Value" = Table.ReplaceValue(#"Filtered Rows1","NodeName:","",Replacer.ReplaceText,{"Nodes"}), #"Trimmed Text" = Table.TransformColumns(#"Replaced Value",{{"Nodes", Text.Trim, type text}}), #"Grouped Rows" = Table.Group(#"Trimmed Text", {"Nodes"}, {{"SW", each _[Column1]}}), #"Create Table" = Table.FromColumns( #"Grouped Rows"[SW],#"Grouped Rows"[Nodes]) in #"Create Table"Please check in attached file.
- TB_VNApr 21, 2021Copper Contributor
Text file contains:
NodeName: Server1
sw
sw
sw
sw
sw
etc..
NodeName: Server2
sw
sw
sw
sw
sw
sw
sw
sw
sw
sw
etc...
NodeName: Server3
sw
sw
sw
sw
sw
sw
etc...
Does this help?