Last active
June 25, 2021 08:48
-
-
Save niconoe/1ca7f21857ad63eb68d25ecddfcd8f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import json | |
source_df = pd.read_csv('./data_agouti.csv') | |
def pd_row_to_dict(row): | |
return { | |
'taxon_id': row['taxon_id'], | |
'scientific_name': row['scientific_name'], | |
'vernacular_names': [ | |
{ | |
'name': row['name_en'], | |
'language': 'en' | |
}, | |
{ | |
'name': row['name_nl'], | |
'language': 'nl' | |
} | |
] | |
} | |
result = [pd_row_to_dict(row) for _, row in source_df.iterrows()] | |
print(json.dumps(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment