Lines.FromText

Lines

Splits a text value into a list of lines.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Lines.FromText(text as text, optional quoteStyle as nullable number, optional includeLineSeparators as nullable logical) as list

Parameters

NameTypeRequiredDescription
texttextYesThe text value to split into lines.
quoteStylenumberNoHow quoted line breaks are handled: QuoteStyle.None (default) or QuoteStyle.Csv.
includeLineSeparatorslogicalNoWhen true, line separator characters are included at the end of each line.

Return Value

listA list of text values, one per line.

Remarks

Lines.FromText splits a text value into a list of lines by breaking on line-feed characters (CR, LF, or CRLF). It is the text-input counterpart to Lines.FromBinary.

This is simpler than Text.Split(text, "#(lf)") because it handles all common line-ending styles automatically (Windows CRLF, Unix LF, and legacy Mac CR).

Examples

Example 1: Split multi-line text

let
    Source = "Alice#(lf)Bob#(lf)Charlie#(lf)Diana",
    Lines = Lines.FromText(Source),
    AsTable = #table({"Index", "Line"}, List.Transform({0..List.Count(Lines)-1}, each {_ + 1, Lines{_}}))
in
    AsTable
Result
Index
Line
11Alice
22Bob
33Charlie
44Diana

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks