Hi,
Below is my code. Hopefully it is in the correct format.

I would like to know how to ask the user the dir and file name of certain file formats (they are red in the code) and have the program take those answers and put them into the program, and re save those files with the correct file format. I have put a small sample below. It is line 11 of the program. 'C:\Temp\TestPy\y08_09sR3.sav' The directory is:C:\Temp\TestPy\. The file name would be: y08_09sR3.sav. Once the user gives the program these parameters I would like to put it into the file below on line 11 and re save it as Compare # 2.asc.

Thanks,
Joe

Example:

*C - *C PSSĀ®MUST 9.1 Response File - Recorded: Saturday, Apr 25,2009 00:31:40 *C - optn 2 9999999 3 1 *blank y pscase 'C:\Temp\TestPy\y08_09sR3.sav' acsolv/opt/adj/1 1/2 0/3 1/4 0/5 1/ gen/1 1/3 0/ sol/1 30/2 0.6/3 0/4 0/5 0.9/7 0.7/8 15/// ACSOLV/LFN *if *MUST_STATUS LE 2 then subs/read 'C:\Temp\TestPy\ACCC-MUST.sub' *blank *endif *if *MUST_STATUS LE 2 then constr 1 2.00000 2 1 3 100 4 3 5 100 6 4 7 0 8 3 9 10000 /y *endif *if *MUST_STATUS LE 2 then read 'C:\Temp\TestPy\OUC.mon' 'C:\Temp\TestPy\FL230-FMPP.con' *blank *endif *if *MUST_STATUS LE 2 then constr//excl/read/ 'C:\Temp\TestPy\NonFirmExclude.exc'// *endif *if *MUST_STATUS LE 2 then must 1 0 2 1 3 50000 4 0.03000 5 3 6 1 7 1 8 0.00000 9 0.00000 10 0.00000 /y *endif *C AC MENU shifts indirectly recorded *C >> MENU SHIFT <<<<<< /3/ MUST 1 0 2 1 3 50000 4 0.02000 5 100 6 0 7 1 8 0.00000 9 0.00000 10 0.00000 /y *C >> MENU SHIFT <<<<<< /3/ACCONT lfopt adj/1 1/2 0/3 1/4 0/5 1/ gen/1 1/3 0 /sol/1 30/2 0.6/3 0/4 0/5 0.9/7 0.7/8 15// opt/1 1/2 2 3 0 4 5/ exe *C *C Select all constraints constra bra/sel/all/ int/sel/all/ fgate/sel/all/ *blank *C *C *C Select all contingencies contin/sel/all/ *C dir/f/'ContSum.lis' *C >> MODIFIED REF TO EXCEL INTERFACE <<<<<< constr/print sum/print bviol/ *C >> REF TO TERMINAL OUTPUT <<<<<< dir/t cont/sel HSEV/100 /constraints/Branch/sel/all *C >> MODIFIED REF TO EXCEL INTERFACE <<<<<< dir/f/MonElRep/ opt/1 100/2 100//pr viol/dir/t// save/'C:\Temp\TestPy\Case1.acc' / /MUST 1 0 2 1 3 50000 4 0.03000 5 3 6 1 7 1 8 0.00000 9 0.00000 10 0.00000 /y /3/ stop [/code tag ends here][code tag starts here]
*C -
*C PSSĀ®MUST 9.1 Response File - Recorded: Saturday, Apr 25,2009 00:31:40
*C -

optn
2 9999999
3 1
*blank
y
pscase
'C:\Temp\TestPy\y08_09sR3.sav'
acsolv/opt/adj/1 1/2 0/3 1/4 0/5 1/
gen/1 1/3 0/
sol/1 30/2 0.6/3 0/4 0/5 0.9/7 0.7/8 15///
ACSOLV/LFN
*if *MUST_STATUS LE 2 then
subs/read
'C:\Temp\TestPy\ACCC-MUST.sub'
*blank
*endif

*if *MUST_STATUS LE 2 then
constr
1 2.00000
2 1
3 100
4 3
5 100
6 4
7 0
8 3
9 10000
/y
*endif

*if *MUST_STATUS LE 2 then
read
'C:\Temp\TestPy\OUC.mon'
'C:\Temp\TestPy\FL230-FMPP.con'
*blank
*endif

*if *MUST_STATUS LE 2 then
constr//excl/read/ 'C:\Temp\TestPy\NonFirmExclude.exc'//
*endif
*if *MUST_STATUS LE 2 then
must
1 0
2 1
3 50000
4 0.03000
5 3
6 1
7 1
8 0.00000
9 0.00000
10 0.00000
/y
*endif
*C AC MENU shifts indirectly recorded
*C >> MENU SHIFT <<<<<<
/3/
MUST
1 0
2 1
3 50000
4 0.02000
5 100
6 0
7 1
8 0.00000
9 0.00000
10 0.00000
/y
*C >> MENU SHIFT <<<<<<
/3/ACCONT
lfopt
adj/1 1/2 0/3 1/4 0/5 1/
gen/1 1/3 0
/sol/1 30/2 0.6/3 0/4 0/5 0.9/7 0.7/8 15//
opt/1 1/2 2
3 0
4 5/
exe
*C
*C Select all constraints
constra
bra/sel/all/
int/sel/all/
fgate/sel/all/
*blank
*C
*C
*C Select all contingencies
contin/sel/all/
*C
dir/f/'ContSum.lis'
*C >> MODIFIED REF TO EXCEL INTERFACE <<<<<<

constr/print sum/print bviol/
*C >> REF TO TERMINAL OUTPUT <<<<<<
dir/t
cont/sel
HSEV/100
/constraints/Branch/sel/all
*C >> MODIFIED REF TO EXCEL INTERFACE <<<<<<
dir/f/MonElRep/ opt/1 100/2 100//pr viol/dir/t//
save/'C:\Temp\TestPy\Case1.acc'
/
/MUST
1 0
2 1
3 50000
4 0.03000
5 3
6 1
7 1
8 0.00000
9 0.00000
10 0.00000
/y
/3/
stop
[/code tag ends here]

Is it just me or does this make no sense? Just to clarify, the code you posted between your "code tag starts/ends here" tags is in what language? Obviously it's not Python, so what is this "correct format" you're taling about?
Are you asking for a program to be written in Python in order to read out the filenames from this block of code above? I just need a better description of what it is you're asking. Thanks.

To use code tags:

[code=python] # This is my PYTHON code # It goes between the code(=syntax) brackets

[/code]

If you use code tags your question will be easier to read, thus easier to answer by our forum members

Yeah, so I take it that is the content of a file or something he wants to read using a Python program so he can find the lines in red, and then change them.... I think?

Once the user gives the program these parameters I would like to put it into the file below on line 11 and re save it as Compare # 2.asc.

Apparently he does want to change the file posted, but since every tutorial covers file read/write, and no effort has been made by the OP to produce any code, -1 to the "write the program for me" posts.

The program is used by a program called MUST. I am not sure how to have python change those lines and then save the entire code with a .asc extention. Do I need to surround the code with " and then how do i save it witn file_name.asc The full program does a lot more in python but the section I don't understand is to make small changes to the MUST code and save the code before MUST runs the Code. Python uses these results and pulls them into excel. Sorry but I can't get to this site from work/ I don't know why but it is filtered.
Thanks Joe

So just a question... do you know any Python code at all? Because the actual program wouldn't be too hard. Regardless of the extension you can read the contents of the file and parse them in Python, then just output them to a new file with the .asc extension.

This question has already been answered. Start a new discussion instead.