处理一些数据,数据来源第一行有的是大写,有的是小写,为了后续处理方便,需要把第一行(标题行)都变成大写。
之前的做法是把Table 转置,第一行(Row)就变成第一列(Column),然后把第一列变成大写,再转置回去,提升第一行作为标题行,总觉得这样做太繁琐,逻辑上讲可以把第一行直接变成大写,再提升其作为标题行。
之前转置方法的code如下(用Table.TransformColumns):
let
Source = Csv.Document(#"Sample File Parameter1",[Delimiter=",", Columns=27, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Transposed Table" = Table.Transpose(Source),//转置
#"Uppercased Text" = Table.TransformColumns(#"Transposed Table",{{"Column1", Text.Upper, type text}}),//把第一行改成大写
#"Transposed Table1" = Table.Transpose(#"Uppercased Text"),//转置回去
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true]),//把第一行作为标题
#"Added Index" = Table.AddIndexColumn(#"Promoted Headers", "Index", 2, 1),
#"Renamed Columns" = Table.RenameColumns(#"Added Index",{{"Index", "Row_No"}})
in
#"Renamed Columns"