diff --git a/src/invoice2data/main.py b/src/invoice2data/main.py index d4b1074d..a32b58c7 100644 --- a/src/invoice2data/main.py +++ b/src/invoice2data/main.py @@ -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 @@ -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()