<!-- https://learnsql.cpetoday.com/functions/m/lines-frombinary -->
# Lines.FromBinary

Language: Power Query M
Category: Data sources
Syntax: Lines.FromBinary(binary, optional includeBlankLines, optional includeLineFeeds, optional encoding)
Summary: Reads binary content, such as a plain text file, and returns it as a list of lines, one item for each line.
Returns: A list of text values, one for each line.
Level: Intermediate
Related: File.Contents, Splitter.SplitTextByPositions, Splitter.SplitTextByDelimiter, Csv.Document, Table.FromList

## 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
- `binary`: the file content, as binary. Usually `File.Contents(path)`.
- `includeBlankLines` (optional): when false, empty lines are removed from the list.
- `includeLineFeeds` (optional): when false, the line-end characters are removed from each line.
- `encoding` (optional): the text encoding, such as `TextEncoding.Windows` or `TextEncoding.Utf8`.

## 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.

```powerquery
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
- A line that is a header, footer or subtotal is still a line. Filter those out by their text, and count the result.
- The encoding must match the file. Garbled characters usually mean the wrong encoding.
- The count of lines is a useful control. Record it before and after the filters.
- For a file that is really comma-separated, Csv.Document is simpler.

## 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.
