from glob import glob as __g
import re
pattern = re.compile(r"/Count\s+(\d+)")
def count():
""" Takes one argument: the path where you want to search the files. Returns a dictionary with the file name and number of pages for each file. """
vPDFfiles = __g( "C:\\1\\" + '*.pdf' )
vMsg = {}
for vPDFfile in vPDFfiles:
vPages = 0
print "File Name is " + str(vPDFfile)
print ""
content = open( vPDFfile, 'rb', 1 ).read()
for match in pattern.finditer(content):
vPages = int(match.group(1))
vMsg[vPDFfile] = vPages
return vMsg
if __name__ == "__main__":
TotalPages=count()
print "Total Pages = " + str(TotalPages)
Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Wednesday, February 11, 2009
Get total Number of pages of a PDF file using Python
Thursday, November 22, 2007
How to fix 'COM Makepy utility' error in Python 2.3.3?
Problem Description :
I have been using Python 2.3 for last 4-5 months without any problem. Today, I have tried installing Python 2.3.3 as well as Python 2.3 pywin32 extensions on Windows 2000 Server. But when I tried to Run 'COM Makepy utility' in PythonWin editor, I got error 'Error executing COM Makepy utility' and no dialog box appeared to allow me to create py equivalent.This is the first time I have received this error. Because of this I am unable to run my application. The same code is running on other Windows XP, 2K and 2003 server machines. I don't understand why this error has started appearing.
Solution:
Please make sure you are using build 210 of pywin32 (see sf.net/projects/pywin32).
Run pywin32-210.win32-py2.3.exe file on the affected pc.
I have been using Python 2.3 for last 4-5 months without any problem. Today, I have tried installing Python 2.3.3 as well as Python 2.3 pywin32 extensions on Windows 2000 Server. But when I tried to Run 'COM Makepy utility' in PythonWin editor, I got error 'Error executing COM Makepy utility' and no dialog box appeared to allow me to create py equivalent.This is the first time I have received this error. Because of this I am unable to run my application. The same code is running on other Windows XP, 2K and 2003 server machines. I don't understand why this error has started appearing.
Solution:
Please make sure you are using build 210 of pywin32 (see sf.net/projects/pywin32).
Run pywin32-210.win32-py2.3.exe file on the affected pc.
Subscribe to:
Posts (Atom)