This is sample code that works for one json file. I need to load credit.json, housingP.json, mood.json, churn.json inside testSplited folder.
def load_test_params():
with open(filePath + '/testsSplited/churn.json') as json_file:
data = json.load(json_file)
assert len(data['tests']) > 0
test_params = data['tests']
return test_params
TEST_PARAMS = load_test_params()
Would be better to use the following pandas trick
import pandas as pd
if __name__ == "__main__":
df = pd.read_json (r'sequencesHost.json')
This is sample code that works for one json file. I need to load credit.json, housingP.json, mood.json, churn.json inside testSplited folder.
def load_test_params():
with open(filePath + '/testsSplited/churn.json') as json_file:
data = json.load(json_file)
assert len(data['tests']) > 0
test_params = data['tests']
return test_params
TEST_PARAMS = load_test_params()
This works using a for loop
def load_test_params():
json_path = filePath + '/testsSplited/'
json_list = [f for f in os.listdir(filePath + '/testsSplited/') if f.endswith('.json')]
for i in json_list:
with open(filePath + '/testsSplited/'+ i) as json_file:
data = json.load(json_file)
assert len(data['tests']) > 0
test_params = data['tests']
return test_params
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.