Skip to content

Instantly share code, notes, and snippets.

@cbilgili
Created July 10, 2018 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbilgili/98bd888f76865582b9110a3a4fbb97b4 to your computer and use it in GitHub Desktop.
Save cbilgili/98bd888f76865582b9110a3a4fbb97b4 to your computer and use it in GitHub Desktop.
Python check if tab separated file is correct
# 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