OpenBI Docs Buy

Lines.FromBinary

Bytes read as text and cut into a list of lines.

Group: Binary and lines. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Lines.FromBinary(binary as binary, optional quoteStyle as any, optional includeLineSeparators as nullable logical, optional encoding as nullable number) as list
ParameterTypeDescription
binarybinaryThe bytes, such as a text file's contents.
quoteStyleany
optional
QuoteStyle.Csv keeps a line break inside double quotes as part of the line; QuoteStyle.None breaks at every line break.
includeLineSeparatorsnullable logical
optional
true to keep each line's line break at its end. Left out, the line breaks are dropped.
encodingnullable number
optional
The text encoding: TextEncoding.Utf8 (the default), TextEncoding.Utf16, TextEncoding.BigEndianUnicode, TextEncoding.Windows, TextEncoding.Ascii, or a code page's number such as 1250.

Returns

list. One text per line.

Remarks

  • A line ends at a carriage return and line feed, a line feed alone, or a carriage return alone.
  • A byte order mark at the start of the bytes is read, and its encoding wins over the one given.

Examples

Lines of a text file

Lines.FromBinary(Text.ToBinary("Oslo#(cr,lf)Bergen#(lf)Trondheim"))
{"Oslo", "Bergen", "Trondheim"}

A quoted note over two lines

With QuoteStyle.Csv the line break inside the quotes belongs to the note.

Lines.FromBinary(Text.ToBinary("Product,Note#(lf)Chair,""oak#(lf)and steel""#(lf)Desk,pine"), QuoteStyle.Csv)
{"Product,Note", "Chair,""oak#(lf)and steel""", "Desk,pine"}

A file in Windows 1252

Lines.FromBinary(#binary({83, 109, 248, 114, 13, 10, 66, 114, 248, 100}), null, null, TextEncoding.Windows)
{"Smør", "Brød"}

Lines.FromText, Text.FromBinary, Csv.Document, File.Contents.

Last updated · OpenBI Studio 0.3.79