跳至主要内容

Table.FromList

將指定的分割函數套用至清單中的每個項目,藉以將清單轉換成資料表。

Syntax

Table.FromList(
list as list,
optional splitter as function,
optional columns as any,
optional default as any,
optional extraValues as ExtraValues.Type
) as table

Remarks

將選擇性分割函數 splitter 套用至清單 list 中的每個項目,藉以將清單轉換成資料表。根據預設,清單會被視為以逗號分隔的文字值清單。選擇性 columns 可能是資料行的數目、資料行清單或 TableType。也可指定選擇性 defaultextraValues

Examples

Example #1

使用預設分割器從清單建立表格。

Table.FromList(
{"a,apple", "b,ball", "c,cookie", "d,door"},
null,
{"Letter", "Example Word"}
)

Result:

Table.FromRecords({
[Letter = "a", #"Example Word" = "apple"],
[Letter = "b", #"Example Word" = "ball"],
[Letter = "c", #"Example Word" = "cookie"],
[Letter = "d", #"Example Word" = "door"]
})

Example #2

使用自訂分割器從清單建立表格。

Table.FromList(
{"a,apple", "b,ball", "c,cookie", "d,door"},
Splitter.SplitByNothing(),
{"Letter and Example Word"}
)

Result:

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"]
})

Example #3

使用 Record.FieldValues 分割器從清單建立表格。

Table.FromList(
{
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
},
Record.FieldValues,
{"CustomerID", "Name"}
)

Result:

Table.FromRecords({
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
})

Category

Table.Table construction