Created
July 10, 2018 21:10
-
-
Save cbilgili/98bd888f76865582b9110a3a4fbb97b4 to your computer and use it in GitHub Desktop.
Python check if tab separated file is correct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It shows if tab seperated file has any error, and print line number | |
# filename = "tab_file.txt" | |
with open(filename) as f: | |
i = 0 | |
for line in f: | |
line = line.rstrip() | |
i = i + 1 | |
if line: | |
try: | |
word, tag = line.split('\t') | |
except ValueError as e: | |
print("[Line %s] %s" % (i, line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment