'How to pass function in terminal with file path as an argument
#I am typing this in terminal or in cmd --> #python pract33.py main "C:\Users\Sharad\Desktop\New folder (2)\GSTR3B.pdf"
#I also know many methods like using "\" or "/" or r etc etc but want to type only the above command in terminal or in cmd and want output as "1".
#this code is to find whether the PDF is proper or not**
from pdfminer import high_level
import re
import os
def main1(vPath):
CT = 0
checkPath = os.path.isfile(vPath)
try:
if checkPath:
if vPath.endswith(".pdf"):
extracted_text = high_level.extract_text(vPath, "")
l = extracted_text.split('\n')
for i in l:
i = i.rstrip()
x = re.findall('[A-Za-z0-9]', i)
if len(x) > 5:
CT += 1
if CT > 20:
print("1")
else:
print("0")
except OSError:
pass
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
