Re: I/O Operations .....



On Apr 30, 2:13 pm, "Daniel Nogradi" <nogr...@xxxxxxxxx> wrote:
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

.



Relevant Pages

  • Re: Help is needed to compile C program using Visual Studie 2005
    ... the pdb file that was used when this precompiled header was created, ... an output file whose name has the following format: ... The length of input file paths and name must be less than 256; ... while(i < DefinedVariableArrayIndex) { ...
    (microsoft.public.vc.language)
  • Re: Need advice on File I/O
    ... open the input file and open an output file, ... you would still have the input file unchanged. ... On all currently supported operating systems, ...
    (comp.soft-sys.matlab)
  • Re: Help with pattern matching
    ... then print the line to an output file. ... > replica of the input file. ... In Perl, CamelBack is generall reserved for package names. ... where their meaning must be expressed in comments. ...
    (perl.beginners)
  • Re: Help with pattern matching
    ... then print the line to an output file. ... > replica of the input file. ... If you had had warnings enabled as well as strict you might have found ... > # Assign the second field to an evaluation scalar ...
    (perl.beginners)
  • Re: Difficult text file to parse.
    ... > records are which there are only two, look at the output file below to ... I want to show the delimiters even if ... > My sample Input file: ... [sample input and output files with long fields snipped] ...
    (comp.lang.perl.misc)