Hello Frappe Community,
I’m currently facing an issue while trying to import data using a CSV file in Frappe 15 Insights. Every time I attempt to import, I receive an “Internal Server Error”.
Environment Details:
- Frappe Version: 15
- Operating System: Windows 11
- Browser: Crome
Expected Outcome:
I expected the data to be imported successfully into the specified module.
Actual Outcome:
I receive an “Internal Server Error” and the import fails.
Error Code:
Traceback (most recent call last):
File "apps/insights/insights/insights/doctype/insights_table_import/insights_table_import.py", line 85, in start_import
table_import._data_source.db.import_table(table_import)
File "apps/insights/insights/insights/doctype/insights_data_source/sources/sqlite.py", line 131, in import_table
df = df[columns_to_import]
~~^^^^^^^^^^^^^^^^^^^
File "env/lib/python3.11/site-packages/pandas/core/frame.py", line 3902, in __getitem__
indexer = self.columns._get_indexer_strict(key, "columns")[1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "env/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6114, in _get_indexer_strict
self._raise_if_missing(keyarr, indexer, axis_name)
File "env/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6178, in _raise_if_missing
raise KeyError(f"{not_found} not in index")
KeyError: "['mr_no_', 'adm_reg__date', 'case_policy_no_', 'clinical_discharge_date_time', 'discharge_date_time', 'discharge_summary_finalized_date_time', 'fathers_mother_spouse_gurdian_name', 'financial_discharge_date_time', 'initiate_discharge_date_time', 'kin_relation_name', 'mobile_no_', 'mrd_case_file_no_', 'new_revisit_patient', 'old_no_', 'patient_current_communication_address', 'period_of_stay_in_days_', 'physical_discharge_date_time', 'pri__employee_id', 'pri__employee_name', 'pri__employee_relationship', 'pri__insurance_company', 'pri__insurance_company_tin_no_', 'pri__member_id', 'pri__plan_name', 'pri__plan_type', 'pri__plan_validity_end', 'pri__plan_validity_start', 'pri__policy_holder_name', 'pri__policy_holder_relationship', 'pri__policy_number', 'pri__prior_auth_id', 'pri__prior_auth_mode_name', 'pri__sponsor', 'pri__sponsor_approval_amt', 'pri__tpa_sponsor_tin_no_', 'relation_cont__no_'] not in index"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 110, in application
response = frappe.api.handle(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/api/__init__.py", line 49, in handle
data = endpoint(**arguments)
^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
return frappe.handler.handle()
^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/handler.py", line 49, in handle
data = execute_cmd(cmd)
^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 1682, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "apps/insights/insights/decorators.py", line 15, in wrapper
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/insights/insights/api/data_sources.py", line 179, in import_csv
table_import.submit()
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 1038, in submit
return self._submit()
^^^^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 1019, in _submit
return self.save()
^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 334, in save
return self._save(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 386, in _save
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1121, in run_post_save_methods
self.run_method("on_submit")
File "apps/frappe/frappe/model/document.py", line 950, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 1316, in composer
return composed(self, method, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 1298, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/model/document.py", line 947, in fn
return method_object(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/insights/insights/insights/doctype/insights_table_import/insights_table_import.py", line 75, in on_submit
self.start_import.enqueue(name=self.name, filepath=self._filepath, now=True)
File "apps/frappe/frappe/__init__.py", line 2220, in <lambda>
f.enqueue = lambda **fun_kwargs: enqueue(f, **task_kwargs, **fun_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 2215, in enqueue
return frappe.utils.background_jobs.enqueue(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/utils/background_jobs.py", line 118, in enqueue
return frappe.call(method, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 1682, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File "apps/insights/insights/insights/doctype/insights_table_import/insights_table_import.py", line 88, in start_import
print(f"Error importing table {table_import.table_name}", e)
BrokenPipeError: [Errno 32] Broken pipe