Files
sshyp/port-jobs/BLANKS.py
T
RandyTheSilly 65e5c31163 port-jobs: Added script for removal of blank lines
Former-commit-id: 207f3b35f60accf85eecbd03e1fd12d914478388
Former-commit-id: 61ea79b06c1af0c70fd7cb3d1b4a6696944ca9fe
2023-04-18 12:58:45 -04:00

17 lines
541 B
Python
Executable File

#!/usr/bin/env python3
from os import listdir
# loop through all Python files in the working directory
for filename in listdir('working'):
if filename.endswith('.py'):
filepath = 'working/' + filename
# read input file
with open(filepath, 'r') as file:
new_file = []
for line in file:
# remove blank lines
if line != '\n':
new_file.append(line)
# write the updated file contents
open(filepath, 'w').writelines(new_file)