Downloads
Power Query MData sourcesIntermediate

Lines.FromBinary

Reads binary content, such as a plain text file, and returns it as a list of lines, one item for each line.

Syntax
Lines.FromBinary(binary, optional includeBlankLines, optional includeLineFeeds, optional encoding)

Returns: A list of text values, one for each line.

What it does

Lines.FromBinary turns a text file into a list of its lines. It is the way to start with a report that is not a true CSV: a fixed-width ledger, a plain text statement or a system log. Each line becomes an item, which you can then split into fields with a splitter.

Syntax and arguments

Example

A legacy system writes a daily ledger as plain text, with blank lines between sections. The query reads the lines, drops the blanks and keeps the rest for splitting.

let
    Source = File.Contents("C:\Legacy\ledger-2026-03-31.txt"),
    Lines = Lines.FromBinary(Source, false, false, TextEncoding.Windows),
    Detail = List.Select(Lines, each Text.Length(_) >= 20),
    Count = List.Count(Detail)
in
    Detail

Lines holds every line, Detail keeps only lines that are long enough to be a transaction, and Count gives the number of transaction lines for the control total. The threshold of 20 characters is a placeholder: set it to suit the layout.

Example: a second, different use

Turning the lines into a table with Table.FromList and then splitting each line by position with Splitter.SplitTextByPositions.

Things to watch

In business terms

Legacy reports and plain text ledgers still show up in close files. Reading them line by line, with a visible filter and a line count, is the kind of control an auditor can follow.

Related functions

All Power Query M functions · View as Markdown · M basics