By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

I/O Operations .....

P: n/a
Hi,
I am parsing an XML file and sending the output to two files.The
code asks the user to enter the input file,something like:

file_input = raw_input("Enter The ODX File Path:")
input_xml = open(file_input,'r')

Now suppose the user enters the path as :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.odx.xml

I have 2 output files to which i have to redirect the output.The
output file name should be same as input file in the same path ( the
extension has to change to a format "ini" which is basically text file
opened using notepad).Eg..
output files should be :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.ini, and,
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.xls

Can someone help me in this.
cheers

Apr 30 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I am parsing an XML file and sending the output to two files.The
code asks the user to enter the input file,something like:

file_input = raw_input("Enter The ODX File Path:")
input_xml = open(file_input,'r')

Now suppose the user enters the path as :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.odx.xml

I have 2 output files to which i have to redirect the output.The
output file name should be same as input file in the same path ( the
extension has to change to a format "ini" which is basically text file
opened using notepad).Eg..
output files should be :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.ini, and,
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.xls
If you only would like to know how to write files, this might help:

content1 = ..............
content2 = ...............

f = open( 'file1', 'w' )
f.write( content1 )
f.close( )

f = open( 'file2', 'w' )
f.write( content2 )
f.close( )
HTH,
Daniel
Apr 30 '07 #2

P: n/a
On Apr 30, 2:13 pm, "Daniel Nogradi" <nogr...@gmail.comwrote:
I am parsing an XML file and sending the output to two files.The
code asks the user to enter the input file,something like:
file_input = raw_input("Enter The ODX File Path:")
input_xml = open(file_input,'r')
Now suppose the user enters the path as :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.odx.xml
I have 2 output files to which i have to redirect the output.The
output file name should be same as input file in the same path ( the
extension has to change to a format "ini" which is basically text file
opened using notepad).Eg..
output files should be :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.ini, and,
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.xls

If you only would like to know how to write files, this might help:

content1 = ..............
content2 = ...............

f = open( 'file1', 'w' )
f.write( content1 )
f.close( )

f = open( 'file2', 'w' )
f.write( content2 )
f.close( )

HTH,
Daniel- Hide quoted text -

- Show quoted text -
Hi,
File writing can be done in that way,but my query is
something different.I have to rename the output file by default with
input file name(only changing the extension.
Thanks

Apr 30 '07 #3

P: n/a
In <11**********************@p77g2000hsh.googlegroups .com>, saif.shakeel
wrote:
File writing can be done in that way,but my query is
something different.I have to rename the output file by default with
input file name(only changing the extension.
Take a look at the functions in `os.path`.

Ciao,
Marc 'BlackJack' Rintsch
Apr 30 '07 #4

P: n/a
I am parsing an XML file and sending the output to two files.The
code asks the user to enter the input file,something like:
file_input = raw_input("Enter The ODX File Path:")
input_xml = open(file_input,'r')
Now suppose the user enters the path as :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.odx.xml
I have 2 output files to which i have to redirect the output.The
output file name should be same as input file in the same path ( the
extension has to change to a format "ini" which is basically text file
opened using notepad).Eg..
output files should be :
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.ini, and,
C:\Projects\ODX Import\Sample Files\Global _A_UHP_Low_0.7.xls
If you only would like to know how to write files, this might help:

content1 = ..............
content2 = ...............

f = open( 'file1', 'w' )
f.write( content1 )
f.close( )

f = open( 'file2', 'w' )
f.write( content2 )
f.close( )

HTH,
Daniel- Hide quoted text -

- Show quoted text -

Hi,
File writing can be done in that way,but my query is
something different.I have to rename the output file by default with
input file name(only changing the extension.

Maybe something like this will help (on Linux, Windows is similar):
>>from os import path
f = '/tmp/hello.xls'
path.splitext( f )
('/tmp/hello', '.xls')
>>path.dirname( f )
'/tmp'
>>path.basename( f )
'hello.xls'
Daniel
Apr 30 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.