Created
February 13, 2018 18:21
-
-
Save ayushgp/e46408afd03fdccee0d506f45b83c5a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
""" | |
Reads a filegiven as CLI arg, puts a number as prefix on each line | |
and adds the seperator between the lines. | |
""" | |
import sys | |
file_name = sys.argv[1] | |
f = open(file_name, 'r', encoding="utf8") | |
contents = f.readlines() | |
f.close() | |
sep = "\n\n===================================================================================\n" | |
for i in range(len(contents)): | |
contents[i] = str(i + 1) + ". " + contents[i] + sep | |
file_contents = "\n".join(contents) | |
f = open(file_name, 'w') | |
f.write(file_contents) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment