### Install Pyresparser Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/index.md Install the pyresparser package using pip. Ensure you have Python and pip installed. ```bash pip install pyresparser ``` -------------------------------- ### Install spaCy and NLTK Models Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/index.md Download necessary models for spaCy and NLTK for NLP operations. These are required for accurate resume parsing. ```bash # spaCy python -m spacy download en_core_web_sm # nltk python -m nltk.downloader words python -m nltk.downloader stopwords ``` -------------------------------- ### Install spaCy NLP model Source: https://github.com/omkarpathak/pyresparser/blob/master/README.rst Download the small English NLP model for spaCy, a dependency for pyresparser. ```bash python -m spacy download en_core_web_sm ``` -------------------------------- ### Extracted Resume Data Structure Source: https://github.com/omkarpathak/pyresparser/blob/master/README.rst Example structure of the dictionary object returned by ResumeParser, containing extracted information from a resume. ```python [ { 'college_name': ['Marathwada Mitra Mandal’s College of Engineering'], 'company_names': None, 'degree': ['B.E. IN COMPUTER ENGINEERING'], 'designation': ['Manager', 'TECHNICAL CONTENT WRITER', 'DATA ENGINEER'], 'email': 'omkarpathak27@gmail.com', 'mobile_number': '8087996634', 'name': 'Omkar Pathak', 'no_of_pages': 3, 'skills': ['Operating systems', 'Linux', 'Github', 'Testing', 'Content', 'Automation', 'Python', 'Css', 'Website', 'Django', 'Opencv', 'Programming', 'C', ...], 'total_experience': 1.83 } ] ``` -------------------------------- ### Display CLI help message Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md View the available command-line arguments and options. ```bash usage: pyresparser [-h] [-f FILE] [-d DIRECTORY] [-r REMOTEFILE] [-sf SKILLSFILE] optional arguments: -h, --help show this help message and exit -f FILE, --file FILE resume file to be extracted -d DIRECTORY, --directory DIRECTORY directory containing all the resumes to be extracted -r REMOTEFILE, --remotefile REMOTEFILE remote path for resume file to be extracted -sf SKILLSFILE, --skillsfile SKILLSFILE custom skills CSV file against which skills are searched for ``` -------------------------------- ### Parse Resume with Custom Skills File Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/index.md Use a custom CSV file for skills matching instead of the default. Ensure the CSV has no headers. ```python from pyresparser import ResumeParser data = ResumeParser('/path/to/resume/file', skills_file='/path/to/skills.csv').get_extracted_data() ``` -------------------------------- ### Basic Resume Parsing Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/index.md Import ResumeParser and extract data from a resume file. This is the primary method for parsing resumes. ```python from pyresparser import ResumeParser data = ResumeParser('/path/to/resume/file').get_extracted_data() ``` -------------------------------- ### Download NLTK words corpus Source: https://github.com/omkarpathak/pyresparser/blob/master/README.rst Download the 'words' corpus for NLTK, another dependency for pyresparser. ```bash python -m nltk.downloader words ``` -------------------------------- ### Parse Resumes from Remote URLs Source: https://context7.com/omkarpathak/pyresparser/llms.txt Fetch and parse resumes directly from remote URLs. The resume is downloaded into memory as a BytesIO object and processed without needing a local file. ```python import io from urllib.request import Request, urlopen from pyresparser import ResumeParser # Fetch remote resume remote_url = 'https://example.com/resumes/candidate.pdf' req = Request(remote_url, headers={'User-Agent': 'Mozilla/5.0'}) webpage = urlopen(req).read() # Create BytesIO object with filename resume_file = io.BytesIO(webpage) resume_file.name = 'candidate.pdf' # Parse remote resume parser = ResumeParser(resume_file) data = parser.get_extracted_data() print(f"Candidate: {data['name']}") print(f"Email: {data['email']}") print(f"Skills: {', '.join(data['skills'] or [])}") ``` -------------------------------- ### Parse multiple resumes from a directory Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md Extract data from all resume files located within a specified directory. ```bash pyresparser -d /path/to/resume/directory/ ``` -------------------------------- ### Pyresparser CLI Usage Source: https://github.com/omkarpathak/pyresparser/blob/master/README.md Command-line interface for running the resume extractor. Supports specifying resume files, directories, remote files, custom regex, skills files, and export formats. ```bash usage: pyresparser [-h] [-f FILE] [-d DIRECTORY] [-r REMOTEFILE] [-re CUSTOM_REGEX] [-sf SKILLSFILE] [-e EXPORT_FORMAT] optional arguments: -h, --help show this help message and exit -f FILE, --file FILE resume file to be extracted -d DIRECTORY, --directory DIRECTORY directory containing all the resumes to be extracted -r REMOTEFILE, --remotefile REMOTEFILE remote path for resume file to be extracted -re CUSTOM_REGEX, --custom-regex CUSTOM_REGEX custom regex for parsing mobile numbers -sf SKILLSFILE, --skillsfile SKILLSFILE custom skills CSV file against which skills are searched for -e EXPORT_FORMAT, --export-format EXPORT_FORMAT the information export format (json) ``` -------------------------------- ### Parse a single resume file Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md Extract data from a local resume file. ```bash pyresparser -f /path/to/resume/file ``` -------------------------------- ### pyresparser CLI Usage Source: https://github.com/omkarpathak/pyresparser/blob/master/README.rst Command-line interface for pyresparser, supporting various options for file input, custom regex, and export formats. ```bash usage: pyresparser [-h] [-f FILE] [-d DIRECTORY] [-r REMOTEFILE] [-re CUSTOM_REGEX] [-sf SKILLSFILE] [-e EXPORT_FORMAT] optional arguments: -h, --help show this help message and exit -f FILE, --file FILE resume file to be extracted -d DIRECTORY, --directory DIRECTORY directory containing all the resumes to be extracted -r REMOTEFILE, --remotefile REMOTEFILE remote path for resume file to be extracted -re CUSTOM_REGEX, --custom-regex CUSTOM_REGEX custom regex for parsing mobile numbers -sf SKILLSFILE, --skillsfile SKILLSFILE custom skills CSV file against which skills are searched for -e EXPORT_FORMAT, --export-format EXPORT_FORMAT the information export format (json) ``` -------------------------------- ### Batch Process Resumes with Multiprocessing Source: https://context7.com/omkarpathak/pyresparser/llms.txt Use a process pool to parse multiple resume files in parallel for improved performance. ```python import os import multiprocessing as mp from pyresparser import ResumeParser def resume_result_wrapper(resume_path): """Wrapper function for multiprocessing""" parser = ResumeParser(resume_path) return parser.get_extracted_data() # Collect all resume files from a directory resume_directory = '/path/to/resumes/' resumes = [] for root, dirs, files in os.walk(resume_directory): for filename in files: if filename.endswith(('.pdf', '.docx', '.doc')): resumes.append(os.path.join(root, filename)) # Process resumes in parallel using all CPU cores pool = mp.Pool(mp.cpu_count()) results = [pool.apply_async(resume_result_wrapper, args=(resume,)) for resume in resumes] parsed_data = [result.get() for result in results] pool.close() pool.join() # Print summary of all candidates for data in parsed_data: print(f"Name: {data['name']}, Experience: {data['total_experience']} years") ``` -------------------------------- ### Parse Single Resume with ResumeParser Source: https://context7.com/omkarpathak/pyresparser/llms.txt Use the ResumeParser class to extract structured data from a local resume file. Supports PDF and DOCX formats. The output includes name, email, mobile, skills, education, experience, and company details. ```python from pyresparser import ResumeParser # Parse a local PDF resume parser = ResumeParser('/path/to/resume.pdf') data = parser.get_extracted_data() print(data) # Output: # { # 'name': 'John Smith', # 'email': 'john.smith@email.com', # 'mobile_number': '555-123-4567', # 'skills': ['Python', 'Machine Learning', 'Django', 'SQL', 'Git'], # 'college_name': ['Stanford University'], # 'degree': ['M.S. IN COMPUTER SCIENCE', 'B.S. IN MATHEMATICS'], # 'designation': ['Software Engineer', 'Data Scientist'], # 'experience': ['Jan 2020 - Present: Senior Developer at Tech Corp'], # 'company_names': ['Tech Corp', 'StartupXYZ'], # 'no_of_pages': 2, # 'total_experience': 4.5 # } ``` ```python # Parse a DOCX file docx_parser = ResumeParser('/path/to/resume.docx') docx_data = docx_parser.get_extracted_data() ``` -------------------------------- ### Remote File Parsing - Parse Resumes from URLs Source: https://context7.com/omkarpathak/pyresparser/llms.txt Fetch and parse resume files directly from remote URLs without manual downloading. ```APIDOC ## Remote File Parsing - Parse Resumes from URLs ### Description Pyresparser can fetch and parse resumes directly from remote URLs without requiring a local file download. The file is downloaded into memory as a BytesIO object and processed like a local file. ### Method Fetch the remote file content and pass a BytesIO object to the `ResumeParser` constructor. ### Endpoint N/A (Python Class) ### Parameters #### Path Parameters - **resume_file** (BytesIO object) - Required - A BytesIO object containing the resume content, with a `name` attribute set to the filename. ### Request Example ```python import io from urllib.request import Request, urlopen from pyresparser import ResumeParser # Fetch remote resume remote_url = 'https://example.com/resumes/candidate.pdf' req = Request(remote_url, headers={'User-Agent': 'Mozilla/5.0'}) webpage = urlopen(req).read() # Create BytesIO object with filename resume_file = io.BytesIO(webpage) resume_file.name = 'candidate.pdf' # Parse remote resume parser = ResumeParser(resume_file) data = parser.get_extracted_data() print(f"Candidate: {data['name']}") print(f"Email: {data['email']}") print(f"Skills: {', '.join(data['skills'] or [])}") ``` ### Response #### Success Response (200) - **name** (string) - The extracted name of the candidate. - **email** (string) - The extracted email address. - **skills** (list of strings) - A list of extracted skills. #### Response Example ```json Candidate: Jane Doe Email: jane.doe@example.com Skills: Python, Data Analysis, SQL ``` ``` -------------------------------- ### Parse with custom skills file Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md Use a custom CSV file containing skills to search against during extraction. ```bash pyresparser -sf /path/to/resume/file.csv -f /path/to/resume/file ``` -------------------------------- ### Calculate Total Work Experience using Pyresparser Source: https://context7.com/omkarpathak/pyresparser/llms.txt Calculate the total work experience in months or years from a list of experience entries. Handles date ranges and the 'present' keyword. Requires date strings in a recognizable format. ```python from pyresparser import utils # Sample experience entries experience_list = [ "Software Engineer at Google: Jan 2018 - Dec 2020", "Senior Developer at Meta: Jan 2021 - present", "Intern at StartupXYZ: Jun 2017 - Aug 2017" ] # Calculate total experience in months total_months = utils.get_total_experience(experience_list) total_years = round(total_months / 12, 2) print(f"Total experience: {total_years} years") # Output: Total experience: 5.67 years # Calculate months between specific dates months = utils.get_number_of_months_from_dates("Jan 2020", "Dec 2022") print(f"Duration: {months} months") # Output: Duration: 35 months # Handle 'present' as end date months_to_present = utils.get_number_of_months_from_dates("Jan 2020", "present") print(f"Duration to present: {months_to_present} months") ``` -------------------------------- ### Parse Resume Sections with Pyresparser Source: https://context7.com/omkarpathak/pyresparser/llms.txt Extract structured data from common resume sections like experience, education, and skills. Two functions are available: one for graduates/undergraduates and another for professionals which includes more section types. ```python from pyresparser import utils resume_text = """ John Smith john@email.com EXPERIENCE Software Engineer at Google Jan 2020 - Present - Developed microservices architecture EDUCATION Stanford University M.S. Computer Science, 2019 SKILLS Python, Java, Machine Learning, AWS """ # Extract sections for graduates/undergraduates sections = utils.extract_entity_sections_grad(resume_text) print(sections) # Output: # { # 'experience': ['Software Engineer at Google', 'Jan 2020 - Present', '- Developed microservices architecture'], # 'education': ['Stanford University', 'M.S. Computer Science, 2019'], # 'skills': ['Python, Java, Machine Learning, AWS'] # } # Extract sections for professionals (includes additional section types) prof_sections = utils.extract_entity_sections_professional(resume_text) ``` -------------------------------- ### Parse a remote resume file Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md Extract data from a resume hosted at a remote URL. ```bash pyresparser -r https://www.example.com/path/to/resume/file ``` -------------------------------- ### Domain-Specific Skill Extraction with Custom Skills File Source: https://context7.com/omkarpathak/pyresparser/llms.txt Extract domain-specific skills by providing a custom CSV file. The CSV should contain skill names, one per column in the first row, without headers. Only skills matching this file will be extracted. ```python from pyresparser import ResumeParser # Create a custom skills CSV file (skills.csv): # Python,Java,JavaScript,Machine Learning,Deep Learning,TensorFlow,PyTorch # Parse resume with custom skills file parser = ResumeParser( '/path/to/resume.pdf', skills_file='/path/to/custom_skills.csv' ) data = parser.get_extracted_data() # Only skills matching your custom file will be extracted print(data['skills']) # Output: ['Python', 'Machine Learning', 'TensorFlow'] ``` -------------------------------- ### CLI Resume Parsing Operations Source: https://context7.com/omkarpathak/pyresparser/llms.txt Perform common parsing tasks via the command line, including single files, directories, and remote URLs. ```bash # Parse a single PDF resume pyresparser -f /path/to/resume.pdf ``` ```bash # Parse all resumes in a directory pyresparser -d /path/to/resumes/ ``` ```bash # Parse a resume from a remote URL pyresparser -r https://example.com/resumes/candidate.pdf # Parse remote file with custom skills pyresparser -r https://example.com/resume.pdf -sf /path/to/skills.csv ``` -------------------------------- ### Specify export format Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md Define the output format for the extracted data. Currently, only JSON is supported. ```bash pyresparser -e json -f /path/to/resume/file ``` -------------------------------- ### Export Parsed Data to JSON Source: https://context7.com/omkarpathak/pyresparser/llms.txt Save extracted resume data into JSON files for external system integration. ```bash # Export single resume to JSON pyresparser -f /path/to/resume.pdf -e json -o /path/to/output.json # Export directory of resumes to JSON pyresparser -d /path/to/resumes/ -e json -o /path/to/all_candidates.json ``` -------------------------------- ### ResumeParser Class - Parse Single Resume Source: https://context7.com/omkarpathak/pyresparser/llms.txt The ResumeParser class is the primary interface for parsing resume files. It can handle various formats and extract essential candidate data. ```APIDOC ## ResumeParser Class - Parse Single Resume ### Description The `ResumeParser` class is the main entry point for extracting data from resume files. It accepts a file path or BytesIO object and returns structured data including name, email, mobile number, skills, education, experience, and company information. The parser automatically detects the file format and uses appropriate extraction methods. ### Method Instantiate the `ResumeParser` class. ### Endpoint N/A (Python Class) ### Parameters #### Path Parameters - **file_path** (string) - Required - The path to the resume file (e.g., PDF, DOCX, DOC). - **skills_file** (string) - Optional - Path to a custom CSV file for domain-specific skill extraction. - **custom_regex** (string) - Optional - A custom regex pattern for parsing phone numbers. ### Request Example ```python from pyresparser import ResumeParser # Parse a local PDF resume parser = ResumeParser('/path/to/resume.pdf') data = parser.get_extracted_data() print(data) ``` ### Response #### Success Response (200) - **name** (string) - The extracted name of the candidate. - **email** (string) - The extracted email address. - **mobile_number** (string) - The extracted mobile number. - **skills** (list of strings) - A list of extracted skills. - **college_name** (list of strings) - A list of extracted college names. - **degree** (list of strings) - A list of extracted degrees. - **designation** (list of strings) - A list of extracted designations. - **experience** (list of strings) - A list of extracted work experiences. - **company_names** (list of strings) - A list of extracted company names. - **no_of_pages** (integer) - The total number of pages in the resume. - **total_experience** (float) - The total work experience in years. #### Response Example ```json { "name": "John Smith", "email": "john.smith@email.com", "mobile_number": "555-123-4567", "skills": ["Python", "Machine Learning", "Django", "SQL", "Git"], "college_name": ["Stanford University"], "degree": ["M.S. IN COMPUTER SCIENCE", "B.S. IN MATHEMATICS"], "designation": ["Software Engineer", "Data Scientist"], "experience": ["Jan 2020 - Present: Senior Developer at Tech Corp"], "company_names": ["Tech Corp", "StartupXYZ"], "no_of_pages": 2, "total_experience": 4.5 } ``` ``` -------------------------------- ### Extract Entities from Text using Pyresparser Utils Source: https://context7.com/omkarpathak/pyresparser/llms.txt Use these utility functions to extract emails, mobile numbers, names, and skills from raw text. spaCy is required for name and skills extraction. Custom regex can be provided for mobile number extraction. ```python import spacy from spacy.matcher import Matcher from pyresparser import utils # Load spaCy model nlp = spacy.load('en_core_web_sm') text = "John Smith john@email.com 555-123-4567 Python Django Machine Learning" doc = nlp(text) # Extract email email = utils.extract_email(text) print(f"Email: {email}") # Output: john@email.com # Extract mobile number mobile = utils.extract_mobile_number(text) print(f"Mobile: {mobile}") # Output: 555-123-4567 # Extract mobile with custom regex mobile_custom = utils.extract_mobile_number(text, custom_regex=r'\d{3}-\d{3}-\d{4}') # Extract name using spaCy matcher matcher = Matcher(nlp.vocab) name = utils.extract_name(doc, matcher) print(f"Name: {name}") # Output: John Smith # Extract skills noun_chunks = list(doc.noun_chunks) skills = utils.extract_skills(doc, noun_chunks) print(f"Skills: {skills}") # Output: ['Python', 'Django', 'Machine Learning'] # Extract skills with custom skills file custom_skills = utils.extract_skills(doc, noun_chunks, skills_file='/path/to/skills.csv') ``` -------------------------------- ### Extract Text from Documents via Utilities Source: https://context7.com/omkarpathak/pyresparser/llms.txt Access low-level text extraction functions directly from the utils module. ```python from pyresparser import utils # Extract text from PDF pdf_text = '' for page in utils.extract_text_from_pdf('/path/to/resume.pdf'): pdf_text += page # Extract text from DOCX docx_text = utils.extract_text_from_docx('/path/to/resume.docx') # Extract text from DOC (requires textract) doc_text = utils.extract_text_from_doc('/path/to/resume.doc') # Generic text extraction (auto-detects format) text = utils.extract_text('/path/to/resume.pdf', '.pdf') # Get number of pages in PDF num_pages = utils.get_number_of_pages('/path/to/resume.pdf') print(f"Resume has {num_pages} pages") ``` -------------------------------- ### Custom Skills File - Domain-Specific Skill Extraction Source: https://context7.com/omkarpathak/pyresparser/llms.txt Utilize a custom CSV file to tailor skill extraction to specific industries or domains. ```APIDOC ## Custom Skills File - Domain-Specific Skill Extraction ### Description By default, Pyresparser uses a built-in skills CSV file. You can provide a custom skills file to extract domain-specific skills relevant to your industry. The CSV file should contain skill names without headers, one per column in the first row. ### Method Instantiate `ResumeParser` with the `skills_file` parameter. ### Endpoint N/A (Python Class) ### Parameters #### Path Parameters - **file_path** (string) - Required - The path to the resume file. - **skills_file** (string) - Required - Path to the custom CSV file containing skills. ### Request Example ```python from pyresparser import ResumeParser # Create a custom skills CSV file (skills.csv): # Python,Java,JavaScript,Machine Learning,Deep Learning,TensorFlow,PyTorch # Parse resume with custom skills file parser = ResumeParser( '/path/to/resume.pdf', skills_file='/path/to/custom_skills.csv' ) data = parser.get_extracted_data() # Only skills matching your custom file will be extracted print(data['skills']) ``` ### Response #### Success Response (200) - **skills** (list of strings) - A list of skills extracted based on the custom skills file. #### Response Example ```json ["Python", "Machine Learning", "TensorFlow"] ``` ``` -------------------------------- ### Provide custom regex for phone numbers Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/cli.md Override the default phone number parsing logic by providing a custom regex pattern. ```bash pyresparser -re '' -f /path/to/resume/file ``` -------------------------------- ### Parse Resume with Custom Phone Number Regex Source: https://github.com/omkarpathak/pyresparser/blob/master/docs/index.md Provide a custom regular expression pattern to parse phone numbers. This allows for flexibility with non-standard phone number formats. ```python from pyresparser import ResumeParser data = ResumeParser('/path/to/resume/file', custom_regex='pattern').get_extracted_data() ``` -------------------------------- ### Configure Custom Phone Number Regex Source: https://context7.com/omkarpathak/pyresparser/llms.txt Override default phone number extraction logic using the -re flag. ```bash # Parse with custom phone regex for international numbers pyresparser -f /path/to/resume.pdf -re '\+\d{1,3}[-.\s]?\d{3}[-.\s]?\d{3}[-.\s]?\d{4}' # Combine with custom skills file pyresparser -f /path/to/resume.pdf -sf /path/to/skills.csv -re '\d{10}' ``` -------------------------------- ### Custom Phone Number Regex for Specific Formats Source: https://context7.com/omkarpathak/pyresparser/llms.txt Provide a custom regex pattern to parse phone numbers in specific formats, such as international numbers or organization-specific formats. This overrides the default phone number parsing. ```python from pyresparser import ResumeParser # Custom regex for UK phone numbers uk_phone_regex = r'(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}' parser = ResumeParser( '/path/to/resume.pdf', custom_regex=uk_phone_regex ) data = parser.get_extracted_data() print(data['mobile_number']) # Output: '+44 7123 456 789' ``` ```python # Custom regex for US phone numbers with extension us_regex = r'\d{3}[-.\]?\d{3}[-.\]?\d{4}(?:\s*(?:ext|x)\.?\s*\d+)?' parser_us = ResumeParser('/path/to/resume.pdf', custom_regex=us_regex) ``` -------------------------------- ### Custom Phone Number Regex - International Number Support Source: https://context7.com/omkarpathak/pyresparser/llms.txt Provide a custom regex pattern to parse phone numbers in specific or international formats. ```APIDOC ## Custom Phone Number Regex - International Number Support ### Description While Pyresparser handles most phone number formats, you can provide a custom regex pattern for parsing phone numbers in specific formats. This is useful for international phone numbers or organization-specific formats. ### Method Instantiate `ResumeParser` with the `custom_regex` parameter. ### Endpoint N/A (Python Class) ### Parameters #### Path Parameters - **file_path** (string) - Required - The path to the resume file. - **custom_regex** (string) - Required - A custom regex pattern for parsing phone numbers. ### Request Example ```python from pyresparser import ResumeParser # Custom regex for UK phone numbers uk_phone_regex = r'(\\+44\\s?7\\d{3}|\\(?07\\d{3}\\)?)\\s?\\d{3}\\s?\\d{3}' parser = ResumeParser( '/path/to/resume.pdf', custom_regex=uk_phone_regex ) data = parser.get_extracted_data() print(data['mobile_number']) # Output: '+44 7123 456 789' # Custom regex for US phone numbers with extension us_regex = r'\\d{3}[-.\\s]?\\d{3}[-.\\s]?\\d{4}(?:\\s*(?:ext|x)\\.?\\s*\\d+)?' parser_us = ResumeParser('/path/to/resume.pdf', custom_regex=us_regex) ``` ### Response #### Success Response (200) - **mobile_number** (string) - The extracted mobile number using the custom regex. #### Response Example ```json "+44 7123 456 789" ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.