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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

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

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 @Anonymous '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

Anonymous
Not applicable

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.