Skip to content

Instantly share code, notes, and snippets.

@jutikorn
Created February 26, 2023 09:03
Show Gist options
  • Save jutikorn/0f78eef98f2c660217467cabbcbfc8b0 to your computer and use it in GitHub Desktop.
Save jutikorn/0f78eef98f2c660217467cabbcbfc8b0 to your computer and use it in GitHub Desktop.
def read_file_line_by_line(filename, pattern):
if not filename.endswith('.kt') and not filename.endswith('.java') and not filename.endswith('.xml'):
print(f' Invalid file. filename is {filename}')
return
try:
with open(filename, 'r', encoding='UTF-8') as file:
while (line := file.readline().rstrip()):
print(line)
except:
print(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment