I/O Operations .....

S

saif.shakeel

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
 
D

Daniel Nogradi

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
 
S

saif.shakeel

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
 
M

Marc 'BlackJack' Rintsch

saif.shakeel said:
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
 
D

Daniel Nogradi

I am parsing an XML file and sending the output to two files.The
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):
'hello.xls'


Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

I/O Error 1
Unusual i/o problems 6
i/o prob revisited 3
Problems in string replacement 0
file Error 3
Element tree errors 1
replacing string in xml file 6
Simple I/O problem can't get solved 6

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top