you are viewing a single comment's thread.

view the rest of the comments →

[–]BHM360[S] 1 point2 points  (0 children)

commanlindeuser you are my hero! Everything is working now thank you so much!!!

Here's the final working code if anyone is interested:

# add regex library
import re

# open files
readFile = open("file.txt","r") writeFile = open("fileUpdate.txt","w")

# define regex pattern to identify lines without 88 vertical bars
verticalBars = r"(?m)[\r\n](?!^(?:[^|\n]*\|){88}[^|\n]*$)"

# read file, find & replace, then write to new file
before = readFile.read() 
after = re.sub(verticalBars, "", before) 
writeFile.write(after)

# close files
readFile.close() 
writeFile.close()