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
Anonymous
Not applicable

Power Query Parameter for Python Script

I would like to export the data via python to csv and set the download file as a parameter in Power query.

I set a parameter called Export_destination = C:\Users\Name\Desktop And I write a python script for export as follows,

 

```

Export_destination = "&Text.From(Export_destination)&"
import pandas as pd
data = pd.DataFrame(dataset)
data.to_csv(r'{Export_destination}\test.csv')

```


However, the script still can not work. Does anyone have a good solution for this question?

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

There probably are other ways, one way is to get your final file in another power query step

Export_destination = Export_destination&"\test.csv" //this is power query step

....

import pandas as pd
data = pd.DataFrame(dataset)
data.to_csv(r'"&Export_destination&"')

 or call the parameter in Python, concat your filename directly...actually you can do dateset.to_csv directly...

import pandas as pd
data = pd.DataFrame(dataset)
data.to_csv(r'"&Export_destination&"\test.csv')

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Could you tell me if @Vera_33 's post helps you? If it is, kindly Accept it as the solution to make the thread closed. More people will benefit from it.

 

Best Regards,
Eyelyn Qin

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

There probably are other ways, one way is to get your final file in another power query step

Export_destination = Export_destination&"\test.csv" //this is power query step

....

import pandas as pd
data = pd.DataFrame(dataset)
data.to_csv(r'"&Export_destination&"')

 or call the parameter in Python, concat your filename directly...actually you can do dateset.to_csv directly...

import pandas as pd
data = pd.DataFrame(dataset)
data.to_csv(r'"&Export_destination&"\test.csv')

 

why is error display that?

 

Andrewlu81_0-1645766712210.png

 

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.

Top Solution Authors