Table.FromList

Syntax

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

About

通过将可选的拆分函数splitter应用到列表中的每个项,list将列表转换为表。 默认情况下,该列表假定为按逗号拆分的文本值列表。 可选 columns 可以是列数、列列表或 TableType。 可选 defaultextraValues 也可以指定。

示例 1

使用默认拆分器从列表中创建表。

用法

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

示例 2

使用自定义拆分器从列表中创建表。

用法

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

示例 3

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