File.Contents

D

T

The M Code Behind the Power Query M function File.Contents

In this article, we’ll take a closer look at the M code behind `File.Contents`. We’ll explore how the function works, how it’s used in Power Query, and how you can modify the code to suit your needs.

Understanding the File.Contents Function

At its core, `File.Contents` is a simple function. It takes a single argument, which is the path to the file you want to read. When you call the function, it reads the contents of the file and returns a table with a single column containing the file’s contents.

Here’s an example:


let

Source = File.Contents(“C:UsersJohnDoeexample.txt”)

in

Source


In this example, we're using `File.Contents` to read the contents of a file named "example.txt" located on the "C:UsersJohnDoe" directory. The function reads the file's contents and returns a table with a single column containing the contents of the file.

The M Code Behind File.Contents

To understand how `File.Contents` works