I have a text file with very specific formatting (it is message policy for a program and the syntax has to be exact). I need to write a python program that can replicate all of the text and formatting in this file (not simply opening and modifying an existing file).
For example, the first few lines in this text file are laid out like so:
SYNTAX_VERSION 5
LOGFILE "FILENAME"
If I were to get Python to replicate this I would have to manually enter into python:
policy = open('D-HFLinux_HDX_Messages.templ.txt','w')
policy.write('SYNTAX_VERSION 5\n\n\n\nLOGFILE "FILENAME"\n DESCRIPTION "DESCRIPTION GOES HERE"')
policy.close()
The problem is the text file is several hundred lines long and manual entry is not an option. Is there some way to import the text file into Python, which would then automatically write a script so when I run that script, Python creates an exact copy of the file?