This is a small program i have written to read a contents from a INPUT FILE containing (+1000 Lines ) and writing simultaneously to another file. ( it works fine )
1.---- QUESTION:-
--------------------
I need to have the same fomat for the written file as of the Reading file ( But the FORMAT is LOST ------ I Dont Know why ?????
2.--------QUESTION:-
--------------------------
-
if want to make a stop at the middle of the file and insert some data to the file and then again perfrom the read and the write operation( HOW CAN I DO THAT)........
import sys
import os
import stat
def ReadFile():
try:
input = open('c:\Abafiles\Job-1.in
p','r')
out = open("exampleWrite.inp", "w")
s = input.readlines()
InputTuple = []
for line in s:
singleLine = line.rstrip()
InputTuple.append(singleLi
ne)
out.write(singleLine)
print len(InputTuple)
except IOError, (errno, strerror):
print "I/O error(%s): %s" % (errno, strerror)
except ValueError:
print "Could not convert data to an integer."
except:
print "Unexpected error:", sys.exc_info()[0]
raise
input.close()
out.close()
ReadFile()
Start Free Trial