"TypeError: can only concatenate list (not "NoneType") to list" in Chart of Accounts Importer

Hi, I got this error when trying to upload the CoA Importer template. Any ideas or suggestion please?

Thanks

Please copy and paste your traceback to identify where the ‘null’ pointer occurs.

Also state your erpnext version, the source of the CofA template, and the steps you followed, to replicate the problem.

This may help explain NoneType https://stackoverflow.com/questions/21095654/what-is-a-nonetype-object

Hi @clarkej,

I got the error as a popup in http://localhost:8080/desk#Form/Chart%20of%20Accounts%20Importer/. Is there any way I can get the traceback?

I tried to attach prefilled template using the attach button in the above link, after I find the correct csv file and hit the upload button, the error message appeared as a popup.

I’m on V12.0.8

Thanks

That can be found in for eg /home/frappe/frappe-bench/logs

For v12 the Importer was refactored apparently https://erpnext.com/docs/user/manual/en/setting-up/chart-of-accounts-importer

A forum search or here https://github.com/frappe/erpnext/issues will inform you with clues

Yeah, I was actually following this one, and only managed to get to step 4 before I got the error.
From the traceback, I got this:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 153, in validate_accounts
    if account["parent_account"] and accounts_dict[account["parent_account"]]:
KeyError: 'Harta'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/error.py", line 36, in make_error_snapshot
    snapshot = get_snapshot(exception)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/error.py", line 131, in get_snapshot
    if type(value)==str and value.startswith(b"u'"):
TypeError: startswith first arg must be str or a tuple of str, not bytes

From SE: You can just convert your list to a tuple and pass it to startswith:
x.endswith(tuple(suffixes))

I’m not a coder, so I don’t really know where to make this changes. Any pointers would be great.

Thanks John @clarkej

Perhaps assume the problem is the data and not the code?

In step 3 in the accounts template you specified a line item ‘Harta’ that this code startswith(b"u'") has a problem with it seems.

So if you specified say this b’u’Harta try ‘Harta’ instead. I think you get the gist.

Be sure to save the csv file as Unicode UTF-8 encoding.

If you get no joy then perhaps the code is the problem…

Another problem I have been experiencing with .csv files and coding / accounts in general, is the fact that some account names have commas in them. In a Comma Separated Value file, a comma obviously represents the next column, and therefore, any commas within the predefined column width, will wreak havoc with imports. Try checking for those characters in your content.

I personally prefer to work with TAB separated files, so that commas are ignored and kept.

Hello guys

I have the same problem, can anyone assist me

below is the traceback:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 63, in get_coa
    forest = build_forest(generate_data_from_csv(file_name))
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 117, in build_forest
    path = return_parent(data, account_name)[::-1]
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py", line 99, in return_parent
    return [child] + return_parent(data, parent_account)
TypeError: can only concatenate list (not "NoneType") to list