Read a file line by line and check line separator : File Utilities : File PYTHON examples


PYTHON examples » File » File Utilities »

 

Read a file line by line and check line separator




import sys
if __name__ == "__main__":
         if len(sys.argv1:
                 try:
                        f = open(sys.argv[1]"rb")
                 except:
                        print "No file named %s exists!" (sys.argv[1],)
                 while 1:
                        t = f.readline()
                        if t == '':
                            break
                        if 'n' in t:
                            t = t[:-1]
                        if 'r' in t:
                            t = t[:-1]
                        sys.stdout.write(t + 'n')
                 f.close()



           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo File
» File Utilities