Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply

Load Python script from file

Hello!

I need to load a Python script fro a file and execute it in Power Query.

The idea is:

 

 

let
    Source = File.Content("python.py"), // or "somefile.txt"
    Script = Python.Execute(Source),
    .... following code
in

 

 

How to skip text splitting and get just the script code into Source?

 

Thanks in advance.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Usually Text.FromBinary ...

 

Note that this opens you to code injection attacks.

Note that the pyton script is supposed to return a dataframe.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Usually Text.FromBinary ...

 

Note that this opens you to code injection attacks.

Note that the pyton script is supposed to return a dataframe.

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.