You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

24 lines
651 B

import shutil
import os
import re
cantoDir = os.path.abspath(os.getcwd())
def main():
"""
Take txt file from `dante-visualized` project and remove blank lines
"""
for txtFile in os.listdir(cantoDir):
if re.search('\.txt$', txtFile):
tmpFile = '.' + txtFile+ '.tmp'
with open(txtFile, 'r') as txt:
with open(tmpFile, 'w') as tmp:
for line in txt:
if line.rstrip():
tmp.write(line)
tmp.close()
txt.close()
shutil.copy(tmpFile, txtFile)
os.remove(tmpFile)
main()