Thursday 12 October 2017

Omitting any line which starts from #,*,@,&, etc

f1=open("OldFile.txt","r")        //Opening old file from which we will fetch the data

f2=open("NewFile.txt","w")     //Opening new file to store the remaining data of old file

while True:
          text=f1.readline()            //fetching data to a variable from old file
          if text[0]=="#":                //here you can change the comparing condition #,*,@,&
                    continue
          f2.write(text)
f2.close()
f1.close()

f1=open("NewFile.txt","r")
print(f1.read())
f1.close()

No comments:

Post a Comment

Python Program to find Fabonacci

fabtab={} def fabonacci(n):     fabtab[0]=0     fabtab[1]=1     for i in range(2,n+1):         fabtab[i]=fabtab[i-1]+fabtab[i-2]         ...