
答案1
您可以在 Windows Excel 2010+ 和 Office 365 中提供的 Power Query 中执行此操作
使用 Power Query
Data => Get&Transform => from Text/CSV
- 当 PQ 编辑器打开时:
Home => Advanced Editor
- 记下文件路径在代码的第 2 行
- 将下面的 M 代码粘贴到您所看到的位置
- 更改文件路径在第 2 行返回最初生成的内容。
- 阅读评论并探索
Applied Steps
以了解算法。- 还可以查看 Microsoft 帮助以了解相关功能
M 代码
let
//import the file
Source = Csv.Document(File.Contents("C:\Users\ron\Desktop\data.csv"),[Delimiter=",", Columns=3,
Encoding=65001, QuoteStyle=QuoteStyle.None]),
//set the data types
#"Changed Type" = Table.TransformColumnTypes(Source,{
{"Column1", type text},
{"Column2", type text},
{"Column3", Int64.Type}
}),
//Pivot on Column2 with no aggregation
#"Pivoted Column" = Table.Pivot(#"Changed Type",
List.Distinct(#"Changed Type"[Column2]), "Column2", "Column3")
in
#"Pivoted Column"