There is a way to execute Power Query by passing parameters to Python. I will try to write this code.
argv2table.py
import pandas as pd
import csv
my_argv = [r'MY_ARGVS']
l = list(csv.reader(my_argv, delimiter=' '))[0]
df = pd.DataFrame(l, columns=['argv'])
The point to note here is that the MY_ARGVS
part at the beginning will be replaced later, so it should never appear again in the code.
In Power Query write
(argv) =>
let
Source = Text.FromBinary(File.Contents("c:\temp\argv2table.py")),
rep = Text.Replace(Source, "MY_ARGVS", argv),
pyexe = Python.Execute(rep),
df1 = pyexe{[Name="df"]}[Value]
in
df1
Do this and try putting the appropriate parameters separated by spaces. This way, a table consisting of each parameter is returned. Since it is divided by csv.reader, it is possible to quote by double quotation. If you pass the Parameter of Power BI, you can change the argument passed to Python from the report screen. However, its practicality is questionable because it asks for Maidomaido Permission.
Recommended Posts