Jump to content
We've recently updated our Privacy Statement, available here. ×

How to pass argument parameters of a python script in IronPython


Hung Huynh

Recommended Posts

Hello,

 

I am currently running a python script in IronPython. How do I pass the argument parameters of my python script into IronPython

p = Process()

p.StartInfo.UseShellExecute = False

p.StartInfo.RedirectStandardOutput = True

 

#Include python executable program path location

p.StartInfo.FileName = "C:Anaconda3python.exe"

 

#Include python script file name

p.StartInfo.Arguments = "BubbleSort.py"

p.Start()Some background info, my python script produces an excel file on my computer so I would like to know the location of that file. That way I can run the rest of my IronPython code that will allow me to open that said file and import to Spotfire. Currently when I hit run in Spotfire, it seems like my python script doesn't execute and produce the excel file, however python script works since I have tested it through a typical Python client (Jupyter Notebook).

I know the below code works however I need help with the argument parameters for my script. Thank you.

clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')

 

from Microsoft.Office.Interop import Excel

 

OpenFile = OpenFileDialog()

OpenFile.ShowDialog()

filePath = OpenFile.FileName

 

#filePath=r"C:sample.csv"

#specify any settings for the file

settings= TextDataReaderSettings()

settings.Separator =","

settings.AddColumnNameRow(0)

dataSource=TextFileDataSource(filePath,settings)

 

dataManager=Document.Data

#datasource name and datasource to add table

dataManager.Tables.Add("DataTable",dataSource)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...