Level: Very Easy
Code the function load_transform_save
that recieves a path to a JSON file, a function and a path to a CSV file.
The function must load the JSON file, apply the function to the data and save the result in the CSV file.
The transformation function must be able to translate the expected input json data to the expeted CSV data.
JSON
[
{
"firstName": "John",
"lastName": "Doe",
"age": 30,
"city": "New York"
},
{
"firstName": "Jane",
"lastName": "Doe",
"age": 25,
"city": "Chicago"
},
{
"firstName": "Bob",
"lastName": "Doe",
"age": 40,
"city": "Los Angeles"
}
]
CSV
name,age,city
J. Doe,30,New York
J. Doe,25,Chicago
B. Doe,40,Los Angeles
import json
import csv
def load_transform_save(path_to_json_file, function, path_to_csv_file):
pass
def main():
pass
if __name__ == "__main__":
main()
If you have any questions please open and issue and we'll reach out to help.