Copy the portion between ----------- and create a validate_ascii.py file with that content.
----------------------
import sys
def validate(filename):
content = None
defective_lines = []
with open(filename, "r") as f:
content = f.readlines()
if content:
for i, line in enumerate(content):
try:
line.encode('ascii')
except UnicodeEncodeError:
defective_lines.append(i+1)
else:
print("There was an issue reading the file. Please try again. ")
return defective_lines
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python3 validate.py ")
sys.exit(1)
result = validate(sys.argv[1])
if not result:
pass
else:
print("Non ascii character at line(s):", result)
----------------------