"Chart of Accounts Importer" cann't import Chinese characters!

When import our Accounts charts, its reports errors!

App Versions

{
	"erpnext": "14.14.0",
	"erpnext_chinese": "13.10.4",
	"frappe": "14.24.0",
	"payments": "0.0.1"
}

Route

Form/Chart of Accounts Importer/Chart of Accounts Importer

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1609, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 26, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 339, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1040, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 909, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1259, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1241, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 906, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 28, in validate
    get_coa(
  File "apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 156, in get_coa
    data = generate_data_from_csv(file_doc)
  File "apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 107, in generate_data_from_csv
    csv_reader = list(csv.reader(in_file))
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 98: invalid continuation byte

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"name\":\"Chart of Accounts Importer\",\"owner\":\"Administrator\",\"modified\":\"2023-03-07 14:23:37.005018\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":\"0\",\"company\":\"MYFirstC\",\"import_file\":\"/private/files/Chart_of_Accounts_Importer-ftea9291.csv\",\"doctype\":\"Chart of Accounts Importer\",\"__last_sync_on\":\"2023-03-07T06:47:43.933Z\",\"__unsaved\":1}",
		"action": "Save"
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 98: invalid continuation byte"
}

two options:

  1. save your csv as Excel, import excel instead
  2. convert your current csv encoding to utf-8 , e.g via notepad++

if you are local Chinese users, you can refer to this FAQ database Issues · 余则霖/ERPNext常见问题 - Gitee.com

Thanks very much!

I can import the file by following your instructions. But it still reports the following errors! But it seems be successful at last even with reporting this issue. Do you know why?

App Versions

{
	"erpnext": "14.14.0",
	"erpnext_chinese": "13.10.4",
	"frappe": "14.24.0",
	"payments": "0.0.1"
}

Route

Form/Chart of Accounts Importer/Chart of Accounts Importer

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1609, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 26, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 339, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1040, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 909, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1259, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1241, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 906, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 28, in validate
    get_coa(
  File "apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 161, in get_coa
    validate_accounts(file_doc, extension)
  File "apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 375, in validate_accounts
    accounts_dict.setdefault(account["account_name"], account)
KeyError: 'account_name'

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"name\":\"Chart of Accounts Importer\",\"owner\":\"Administrator\",\"modified\":\"2023-03-07 17:01:34.401145\",\"modified_by\":\"peibin.lin@photon-counting.cn\",\"docstatus\":0,\"idx\":\"0\",\"company\":\"TESTCom\",\"import_file\":\"/private/files/Chart_of_Accounts_Importer-ft-u8.csv\",\"doctype\":\"Chart of Accounts Importer\",\"__last_sync_on\":\"2023-03-08T05:15:05.444Z\",\"__unsaved\":1}",
		"action": "Save"
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "KeyError: 'account_name'"
}