Downloads
Power Query MData sourcesBeginner

File.Contents

Reads one file from disk and returns its content as binary, ready to be read by a file-type function.

Syntax
File.Contents(path)

Returns: The file's content as binary.

What it does

File.Contents reads a single file and hands its bytes to Power Query. The bytes are not yet a table. You then pass them to the function that understands the file type: Excel.Workbook for a workbook, Csv.Document for a comma-separated file, Json.Document for JSON, or Lines.FromBinary for plain text. Use it when you know exactly which file you want.

Syntax and arguments

Example

A bank statement for March arrives as a CSV on a shared drive. The query reads the file and takes the rows.

let
    Source = File.Contents("C:\Banking\statement-2026-03.csv"),
    Statement = Csv.Document(Source, [Delimiter = ",", Encoding = TextEncoding.Utf8]),
    Headers = Table.PromoteHeaders(Statement, [PromoteAllScalars = true])
in
    Headers

Source is the raw file, and Csv.Document turns it into a table. The header row is then promoted to column names.

Example: a second, different use

Reading a single workbook: Excel.Workbook(File.Contents("C:\Finance\Close\accruals.xlsx"), true) gives the sheets in that workbook.

Things to watch

In business terms

Single statements, a fixed set of schedules or a policy file are often read from a known path. Documenting the path in the query keeps the monthly process repeatable for whoever runs it next.

Related functions

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