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

'NoneType' object is not subscriptable error when yelp_academic_dataset_business.json conversion #56

Open
zoldaten opened this issue Apr 26, 2021 · 0 comments

Comments

@zoldaten
Copy link

zoldaten commented Apr 26, 2021

I`ve converted all datasets in yelp_dataset except yelp_academic_dataset_business.json.
It returns a error:

Traceback (most recent call last):
  File "json_to_csv_converter2.py", line 129, in <module>
    read_and_write_file(json_file, csv_file, column_names)
  File "json_to_csv_converter2.py", line 21, in read_and_write_file
    csv_file.writerow(get_row(line_contents, column_names))
  File "json_to_csv_converter2.py", line 97, in get_row
    column_name,
  File "json_to_csv_converter2.py", line 89, in get_nested_value
    return get_nested_value(sub_dict, sub_key)
  File "json_to_csv_converter2.py", line 84, in **get_nested_value**
    return d[key]
TypeError: 'NoneType' object is not subscriptable

I`ve changed in script from:

if '.' not in key:
        if key not in d:
            return None
        return d[key]

to

if '.' not in key:
        if d==None:
            return None
        elif key not in d:
            return None
        return d[key]

and problem solved. But i do not think that`s the right way...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant