[英]I have a data file in json format. How can I find and print the top 20 eij_max values and the associated pretty_formula? I am using python
Here is part of the data file in json format, containing 1 entry.这是json格式的数据文件的一部分,包含1个条目。 I need to find the 20 compounds (key:pretty_formula) with the highest eij_max values.
我需要找到具有最高 eij_max 值的 20 个化合物 (key:pretty_formula)。 I appreciate the help, I apologise if this is a basic question, I am new to all this.
感谢您的帮助,如果这是一个基本问题,我深表歉意,我对这一切都很陌生。
{
"num_results": 3402,
"valid_response": true,
"criteria": "{\"piezo\": {\"$ne\": null}}",
"properties": "[\"pretty_formula\", \"piezo\", \"eij_max\", \"band_gap\", \"energy\"]",
"response": [
{
"pretty_formula": "KMg(PO3)3",
"piezo": {
"eij_max": 0.09337344787836212,
"piezoelectric_tensor": [
[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0660250018229951
],
[
0.06602500182299509,
-0.06602499453211871,
0.0,
0.0,
0.0,
0.0
],
[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
],
"v_max": [
-0.0,
1.0,
0.0
]
},
"eij_max": null,
"band_gap": 4.9474,
"energy": -193.18215352
},
{
"pretty_formula": "Sr2CuSi2O7",
You can easily do something like this to access the eij_max
:您可以轻松地执行以下操作来访问
eij_max
:
import json
# Opening JSON file
f = open('data.json',)
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for i in data['response']['piezo']['eij_max']
print(i)
# Closing file
f.close()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.