I've perused the other topics related to this question, but none have directly answered the question. I'm hoping that perhaps you all can help.
I'm working on cleaning up a Wordpress Theme which has been long abused and uncleaned. We have about 10-12 CSS files that aren't being used. Just before I was going to delete them, I was told that some of the files may have been referenced in the actual content in the site. Shudder I'm using Python to search the line for the name of the file. If it finds the name, it renders the line from the file it was located, and the line in its entirety. Lastly it displays the end results and closes the files, etc. Here is the code. (Heads up... I'm not the most comfortable with Python.)
cssfile = open("css.txt", "r")
s = open("berea.sql", "r", encoding="utf-8")
totalfound = 0
lineinfile = 0
for filename in cssfile:
for line in s:
lineinfile = lineinfile+1
for filename in line:
print (lineinfile, line)
totalfound = totalfound+1
lineinfile=0
if totalfound == 0:
print ("No results were found for %s") % filename
else:
print ("We found %i of %s in the database") % (totalfound, filename)
cssfile.close()
searchfile.close()
Honestly, the biggest problem comes from the encoding error I receive.
UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in position
445: character maps to <undefined>
I've seen that adding different decodes, encodes, etc. should fix it, but nothing seems to work... I would appreciate any and all assistance. I have about 349,000 lines to search through, and I keep getting stopped at 830.