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
| Parameter | Type | Description |
|---|---|---|
binary | binary | The bytes, such as a text file's contents. |
quoteStyle | any optional | QuoteStyle.Csv keeps a line break inside double quotes as part of the line; QuoteStyle.None breaks at every line break. |
includeLineSeparators | nullable logical optional | true to keep each line's line break at its end. Left out, the line breaks are dropped. |
encoding | nullable 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"}
Related functions
Lines.FromText, Text.FromBinary, Csv.Document, File.Contents.