/ Published in: Python
This script is used for the sorted text.
Expand |
Embed | Plain Text
#!/usr/bin/env python # -*- coding: utf-8 -*- filein = "./inputdata.txt" fileout = "./outputdata.txt" r = open(filein,'r') w = open(fileout,'w') tmp = "" for line in r: if (tmp != line): w.write(line) tmp = line r.close() w.close()
Comments
Subscribe to comments
You need to login to post a comment.

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. :-)
I did not know this command 'uniq'. Thank you!