Hi,
I want to read a line in the file and check the content in the line, for example if the line starts with the text "sample test ..." i want to check wether the line starts with sample, but my code always return no result even thou the file contains "sample test ..."
code:
import os
import string
root = "\home\sathappan"
inputfile = os.path.join(root,"data.txt")
outputfile = os.path.join(root,"dataexp.bat")
a = open(inputfile)
b = open(outputfile,"a")
while 1:
line = a.readline().strip()
if line == 'Sample*':
print line
b.write(line)
a.close()
b.close()
data.txt
example 123
test test
sample text
sampe test line
text line
ex test