I want to edit a text document which having page number at the end of every 10-12 line (conversion of PDF into text and having page number at end of page). I want to remove these particular page number integer not in text as there can a page number 50 but also can be a line in which there can be 50 as integer. So I want to remove only the line which has page number integer.
Example of text document:
1
militant Muslims use scriptures such as the
Genesis story describing the destruction of
Sodom and Gomorrah as justification (from Allah)
for the hatred they vent on all things non-
Muslim and especially on gay men.
2
A Word from the Author
Today, in the 21st Century the majority of Muslims
hold middle
3
Into The Darkness
the driver assured the exhausted travelers who
were dozing fitfully in the rear of the van, they
4
down. It blocked the narrow road.
Ali Azzizi was the other man accompanying
the women.
5
I want the remove these page number from 1-5 but if these same number appear anywhere in between line it should not removed.
My code
filename = input('filname')
filedata = None
temp = 1
with open(filename, 'r', encoding="utf8") as file:
filedata = file.read()
filedata.join(line.strip() for line in file)
rahul = ' '
for line in file:
if(line=='1'):
filedata = filedata.replace(line, ' ')
with open(filename, 'w', encoding="utf8") as file:
file.write(filedata)