Table.FromList
Table.FromList(list as list, optional splitter as nullable function, optional columns as any, optional default as any, optional extraValues as nullable number) as table
將選擇性list
套用至清單中的每個項目,以將清單 splitter
轉換成資料表。 根據預設,清單會假設為以逗號分隔的文字值清單。 選擇性 columns
可以是資料行數目、資料行清單或 TableType。 還可指定選擇性 default
和 extraValues
。
使用預設分隔器,從清單建立資料表。
使用方式
Table.FromList(
{"a,apple", "b,ball", "c,cookie", "d,door"},
null,
{"Letter", "Example Word"}
)
輸出
Table.FromRecords({
[Letter = "a", #"Example Word" = "apple"],
[Letter = "b", #"Example Word" = "ball"],
[Letter = "c", #"Example Word" = "cookie"],
[Letter = "d", #"Example Word" = "door"]
})
使用自訂分隔器,從清單建立資料表。
使用方式
Table.FromList(
{"a,apple", "b,ball", "c,cookie", "d,door"},
Splitter.SplitByNothing(),
{"Letter and Example Word"}
)
輸出
Table.FromRecords({
[#"Letter and Example Word" = "a,apple"],
[#"Letter and Example Word" = "b,ball"],
[#"Letter and Example Word" = "c,cookie"],
[#"Letter and Example Word" = "d,door"]
})
使用 Record.FieldValues 分割器從清單中建立數據表。
使用方式
Table.FromList(
{
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
},
Record.FieldValues,
{"CustomerID", "Name"}
)
輸出
Table.FromRecords({
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
})