Posted By

kyokutyo on 09/26/08


Tagged

delete line


Versions (?)

delete overlapping line


 / Published in: Python
 

This script is used for the sorted text.

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. filein = "./inputdata.txt"
  5. fileout = "./outputdata.txt"
  6.  
  7. r = open(filein,'r')
  8. w = open(fileout,'w')
  9. tmp = ""
  10.  
  11. for line in r:
  12. if (tmp != line):
  13. w.write(line)
  14. tmp = line
  15.  
  16. r.close()
  17. w.close()

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ishmael78 on December 4, 2008

in bash, maybe such way is more easy...

uniq inputdata.txt > outputdata.txt

I don't know the exact context you met, just mention it by the way. :-)

Posted By: kyokutyo on January 20, 2009

I did not know this command 'uniq'. Thank you!

You need to login to post a comment.