Skip to content

[WIP] Handle JSON data files in import_from_config #627

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zarino
Copy link
Member

@zarino zarino commented Jan 8, 2025

Largely untested!!

Enables import_from_config to create a Pandas DataFrame from a list of dictionaries in a JSON file, in addition to rows in CSV and Excel files.

To handle complex JSON files (where the root element isn’t just a list of the items/rows you want to import), we allow the config file to specify a jsonpath expression, which is used to identify the bit of the JSON object that we want to pull out.

I wrote this code, hoping to import some data from a JSON file, but then realised the JSON file lacked constituency IDs, so would need to be geocoded first, making this change redundant (since whatever script does the geocoding could also output CSV instead of JSON). But maybe this code might be useful in future..?

Largely untested!!

Enables import_from_config to create a Pandas DataFrame from a list of
dictionaries in a JSON file, in addition to rows in CSV and Excel files.

To handle complex JSON files (where the root element isn’t just a list
of the items/rows you want to import), we allow the config file to
specify a jsonpath expression, which is used to identify the bit of the
JSON object that we want to pull out.

I wrote this code, hoping to import some data from a JSON file, but then
realised the JSON file lacked constituency IDs, so would need to be
geocoded first, making this change redundant (since whatever script
does the geocoding could also output CSV instead of JSON). But maybe
this code might be useful in future..?
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

Successfully merging this pull request may close these issues.

1 participant