How to fix "DataSource.Error Access to the path '/yourpath.csv' is denied error" in macOS Excel Power Query
![excel error box: [DataSource.Error] Access to the path '/Users/dan/Dropbox/mybook/mydata.csv' is denied.](https://private-user-images.githubusercontent.com/121520/417265627-35694df6-ecc2-4dd2-b94f-a2dcbc15f040.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDM2MTIxMTQsIm5iZiI6MTc0MzYxMTgxNCwicGF0aCI6Ii8xMjE1MjAvNDE3MjY1NjI3LTM1Njk0ZGY2LWVjYzItNGRkMi1iOTRmLWEyZGNiYzE1ZjA0MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNDAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDQwMlQxNjM2NTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05ZDdjYzk5YzRlYTZkMmMyMGQzM2E1NGY5NzMyY2E0MmNkZGQ4YWY5MzhhNTljNzUwNTUxYTBjMDBkYzQ3YzkyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.53GHET-fIw60ktBAtysizmdtSfEqm30YIUdQB56YJI4)
One of the most incomprehensible errors I have ever run into, with Microsoft forums and ChatGPT/Claude being almost totally useless. Hopefully anyone else running into this situation will come across this gist and save themselves hours of frustration.
Huge thanks to Mr. Excel for the solution, with a major assist by r/excel
![power query editor error [DataSource.Error] Access to the path '/Users/dan/Dropbox/mybook/mydata.csv' is denied.](https://private-user-images.githubusercontent.com/121520/417265308-56941b26-5f59-4f02-a868-2d123a081888.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDM2MTIxMTQsIm5iZiI6MTc0MzYxMTgxNCwicGF0aCI6Ii8xMjE1MjAvNDE3MjY1MzA4LTU2OTQxYjI2LTVmNTktNGYwMi1hODY4LTJkMTIzYTA4MTg4OC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNDAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDQwMlQxNjM2NTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZTJkMDY3MzEyNWQ3MTkyMDFkNjU0ZmE5YTliZTZhZmZjYjM4MDVlOGZiMTExMWVjZmI5M2FlOTU2ZDM1M2U1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.kfRA5VLNbHqOTxuEPrpUuvSPGgSHLFqGF_XbIdcMh5U)
So you're trying to use macOS Excel's Power Query Editor to load an external file from disk, e.g. /Users/dan/Dropbox/mybook/mydata.csv
, only to get this error:
• [DataSource.Error] Access to the path '/Users/dan/Dropbox/mybook/mydata.csv' is denied.
Details
isRecoverable: True
isExpected: True
I ran into this error when saving a workbook on Dropbox, and then trying to open and work on it from a different laptop. Opening the Excel workbook was fine, the error message came from the Power Query command that imported the CSV, e.g.
let
Source = Csv.Document(
File.Contents("/Users/dan/Dropbox/mybook/mydata.csv"),
[Delimiter = ",", Columns = 2, QuoteStyle = QuoteStyle.None]
)
in
Source
The computer that originally created and saved the workbook had no problems re-opening the book and working with the Power Query command. The other laptop just utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.
tl;dr: Have Excel ask you to grant access to that file. But since Excel (in my experience) won't even know to do that, you can force it to with a simple VB command referencing the file path.
Go to the Microsoft Visual Basic editor inside of Excel (i.e. Developer ribbon » Visual Basic)

Then open up the "Immediate" code window, i.e. View » Immediate Window or use the keyboard shortcut Ctrl-Cmd-G.
Enter, then execute following benign code which simply tries to print the directory of the data file via a message alert box:
(obviously, replace with the absolute path to the file you're trying to access)
MsgBox Dir("/Users/dan/Dropbox/mybook/mydata.csv")

Executing that line of code will bring up a dialog box asking you to manually grant access to the given file.
Additional permissions are required to access the following files: /Users/dan/Dropbox/mybook/mydata.csv Microsoft Excel needs access to the file named "mydata.csv". Select the item to grant access.

Select the file and grant access:

It will likely ask you to grant access to the enclosing folder, so do that too:

The MsgBox
command should successfully execute:

Save, and restart Excel. You should be good to go.
Note: You have to completely exit out of Excel, not just close the file.
You already need to do this step anyway, whether you're on macOS or Windows:
In the Power Query Editor » Options » Privacy, be sure to enable the option that says:
Allow combining data from multiple sources. This could expose sensitive or confidential data to an unauthorized person.
