File.Contents
Reads one file from disk and returns its content as binary, ready to be read by a file-type function.
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
path: the full path to the file, as text, such as"C:\Banking\statement.csv". Use a parameter for the path if it changes each month.
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
- The path must be reachable by the account that runs the refresh. A path on your own PC may not exist on a server.
- A file that is open in another program may be locked. Close it before the refresh.
- Use a relative or parameterized path when the file moves between machines, and document the location.
- For many files, use Folder.Files, which handles the list for you.
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.