21 lines
431 B
Python
21 lines
431 B
Python
from json import load
|
|
from pandas import json_normalize, DataFrame
|
|
from constants import files, columns
|
|
|
|
|
|
def open_json(dataset):
|
|
with open(files[dataset]) as f:
|
|
json = load(f)
|
|
return json
|
|
|
|
|
|
def create_dataframe(dataset):
|
|
json = open_json(dataset)
|
|
df = json_normalize(
|
|
data=json["records"],
|
|
record_path=["fields"],
|
|
meta=columns[dataset],
|
|
errors="ignore",
|
|
)
|
|
return df
|