方法很多,不唯一。 除最后2步需简单修改公式,其他点点菜单就行了。
let
源 = Csv.Document(File.Contents("C:\Users\Administrator\Downloads\agency lists.txt"),[Delimiter=":", Columns=2, Encoding=936, QuoteStyle=QuoteStyle.None]),
更改类型 = Table.TransformColumnTypes(源,{{"Column1", type text}, {"Column2", type text}}),
筛选的行 = Table.SelectRows(更改类型, each ([Column1] "")),
已添加索引 = Table.AddIndexColumn(筛选的行, "索引", 0, 1),
插入的整除 = Table.AddColumn(已添加索引, "整除", each Number.IntegerDivide([索引], 8), Int64.Type),
插入的取模 = Table.AddColumn(插入的整除, "取模", each Number.Mod([索引], 8), type number),
已添加条件列 = Table.AddColumn(插入的取模, "field", each if [取模] = 0 then "Name" else if [取模] = 1 then "Address" else [Column1]),
已添加条件列1 = Table.AddColumn(已添加条件列, "value", each if [取模] = 0 then [Column1] else if [取模] = 1 then [Column1] else [Column2]),
删除的其他列 = Table.SelectColumns(已添加条件列1,{"整除", "field", "value"}),
分组的行 = Table.Group(删除的其他列, {"整除"}, {{"table", each #table(_[field],{_[value]})}}),
自定义1 = Table.Combine(分组的行[table])
in
自定义1 |