Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract_data input_module kwarg accepts strings #266

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/invoice2data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
output_mapping = {"csv": to_csv, "json": to_json, "xml": to_xml, "none": None}


def extract_data(invoicefile, templates=None, input_module=pdftotext):
def extract_data(invoicefile, templates=None, input_module='pdftotext'):
"""Extracts structured data from PDF/image invoices.

This function uses the text extracted from a PDF file or image and
Expand Down Expand Up @@ -75,6 +75,8 @@ def extract_data(invoicefile, templates=None, input_module=pdftotext):
'currency': 'INR', 'desc': 'Invoice IBZY2087 from OYO'}

"""
if type(input_module) == str:
input_module = input_mapping[input_module]
if templates is None:
templates = read_templates()

Expand Down