Skip to content

Instantly share code, notes, and snippets.

@bjulius
Created February 29, 2024 00:52
Show Gist options
  • Save bjulius/9940423079e266bf40914ccacf77499f to your computer and use it in GitHub Desktop.
Save bjulius/9940423079e266bf40914ccacf77499f to your computer and use it in GitHub Desktop.
List. Accumulate vs List Transform
let
Source = {1..100000},
Accumulate =
List.Accumulate(
Source,
"",
( state, current ) => state & ( if state = "" then "" else ", " ) & Text.From( current )
),
SplitToList = List.Buffer( Text.Split(Accumulate, """, """)),
ConvertToTable = Table.FromList(SplitToList, Splitter.SplitByNothing(), {"Number"}, null, ExtraValues.Error),
SplitToRows = Table.ExpandListColumn(Table.TransformColumns(ConvertToTable, {{"Number", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Number")
in
SplitToRows
let
Source = {1..100000},
Transform = Text.Combine( List.Transform( Source, each Text.From(_)), ", "),
SplitToList = List.Buffer( Text.Split(Transform, """, """)),
ConvertToTable = Table.FromList(SplitToList, Splitter.SplitByNothing(), {"Number"}, null, ExtraValues.Error),
SplitToRows = Table.ExpandListColumn(Table.TransformColumns(ConvertToTable, {{"Number", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Number")
in
SplitToRows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment