I am trying to get some values stored in a JSON file through python 3.7. The file contain values but it is returning null.
Here is the JSON file:
{
"data_columns":[
"yearsexperience",
"milesfrommetropolis",
"ceo",
"cfo",
"cto",
"janitor",
"junior",
"manager",
"senior",
"vice president",
"bachelors",
"doctoral",
"high school",
"masters",
"others",
"biology",
"business",
"chemistry",
"computer science",
"engineering",
"literature",
"math",
"none",
"physics",
"automobile",
"education",
"finance",
"health",
"oil",
"service",
"web"
]
}
And here is how I am trying to fetch the values:
import json, pickle
__jobType = None
__data_columns = None
__model = None
def get_jobtpye():
return __jobType
def load_saved_artifacts():
print('Loading saved artifacts!')
global __jobType
global __data_columns
with open("./artifacts/columns.json", 'r') as f:
__data_columns = json.load(f)['data_columns']
__jobType = __data_columns[2:10]
if __name__ == '__main__':
load_saved_artifacts()
get_jobtpye()
When I am checking if the __jobType
variable contains any thing, then i am finding that it does. It just won't return anything. I have been stuck in this problem for a week now. Please help.