Skip to content

Instantly share code, notes, and snippets.

@OhadRubin
Created October 1, 2024 09:35
Show Gist options
  • Save OhadRubin/73ad80ad6b1b04bb9dc4b0973c21ba19 to your computer and use it in GitHub Desktop.
Save OhadRubin/73ad80ad6b1b04bb9dc4b0973c21ba19 to your computer and use it in GitHub Desktop.
add_line_numbers.py
def add_line_numbers(input_file, output_file):
with open(input_file) as f:
text = f.read()
output_text = "\n".join([f"{i} {line}" for i, line in list(enumerate(text.split("\n")))])
with open(output_file, "w") as f:
f.write(output_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment