2020-05-27 20:13:45 +02:00
|
|
|
from json import load
|
2020-05-27 20:45:21 +02:00
|
|
|
from pandas import json_normalize, DataFrame
|
|
|
|
from app.constants import files
|
2020-05-27 20:13:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
def open_json(dataset):
|
|
|
|
with open(files[dataset]) as f:
|
|
|
|
json = load(f)
|
|
|
|
return json
|
|
|
|
|
|
|
|
|
|
|
|
def create_dataframe(dataset):
|
|
|
|
json = open_json(dataset)
|
|
|
|
data = json_normalize(data=json["records"])
|
|
|
|
df = DataFrame.from_dict(data=data)
|
|
|
|
return df
|