Database
2019. 12. 4. 23:38
1) Modify a JSON file to avoid import error
[{'task_id': 'mp-1', 'icsd_id': None, 'icsd_ids': [626969, 44754, 76941, 626975, 426937], 'p
retty_formula': 'Cs', 'e_above_hull': 0.03657077379310347, 'band_gap': 0.0, 'volume': 114.04
133630947751, 'density': 1.9352166385518854, 'diel': None, 'cif': "# generated using pymatge
n\ndata_Cs\n_symmetry_space_group_name_H-M 'P 1'\n_cell_length_a 5.28278343\n_cell_lengt
h_b 5.28196921\n_cell_length_c 5.28280095\n_cell_angle_alpha 109.67273530\n_cell_angle
_beta 108.65561774\n_cell_angle_gamma 109.67203879\n_symmetry_Int_Tables_number 1\n_ch
emical_formula_structural Cs\n_chemical_formula_sum Cs1\n_cell_volume 114.04133631\n_c
ell_formula_units_Z 1\nloop_\n _symmetry_equiv_pos_site_id\n _symmetry_equiv_pos_as_xyz\n
1 'x, y, z'\nloop_\n _atom_site_type_symbol\n _atom_site_label\n _atom_site_symmetry_multi
plicity\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n _atom_site_occupanc
y\n Cs Cs1 1 0.000025 0.000006 0.999997 1\n"}]
[{'task_id': 'mp-2', 'icsd_id': None, 'icsd_ids': [64918, 648679, 52251, 180870, 648674, 778
85, 64922, 64914, 648675, 648676, 41517, 64916, 180871, 64915, 648673, 426965, 64920, 76148,
648677, 648680], 'pretty_formula': 'Pd', 'e_above_hull': 0, 'band_gap': 0.0, 'volume': 15.4
90309950598192, 'density': 11.40807157509303, 'diel': None, 'cif': "# generated using pymatg
en\ndata_Pd\n_symmetry_space_group_name_H-M 'P 1'\n_cell_length_a 2.79806867\n_cell_leng
th_b 2.79806867\n_cell_length_c 2.79806867\n_cell_angle_alpha 60.00000000\n_cell_angle
_beta 60.00000000\n_cell_angle_gamma 60.00000000\n_symmetry_Int_Tables_number 1\n_chem
ical_formula_structural Pd\n_chemical_formula_sum Pd1\n_cell_volume 15.49030995\n_cell
_formula_units_Z 1\nloop_\n _symmetry_equiv_pos_site_id\n _symmetry_equiv_pos_as_xyz\n 1
'x, y, z'\nloop_\n _atom_site_type_symbol\n _atom_site_label\n _atom_site_symmetry_multipli
city\n _atom_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n _atom_site_occupancy\n
Pd Pd1 1 0.000000 0.000000 0.000000 1\n"}]
Convert like this (using notepad++): Basically strings should be enclosed by single/double quotes. Array of intergers seems not recognized. So they are changed to strings.
[
{'task_id': 'mp-1', 'icsd_ids': '626969, 44754, 76941, 626975, 426937', 'pretty_formula': '
Cs', 'e_above_hull': 0.03657077379310347, 'band_gap': 0.0, 'volume': 114.04133630947751, 'de
nsity': 1.9352166385518854, 'diel': 'None', 'cif': "# generated using pymatgen\ndata_Cs\n_sy
mmetry_space_group_name_H-M 'P 1'\n_cell_length_a 5.28278343\n_cell_length_b 5.2819692
1\n_cell_length_c 5.28280095\n_cell_angle_alpha 109.67273530\n_cell_angle_beta 108.655
61774\n_cell_angle_gamma 109.67203879\n_symmetry_Int_Tables_number 1\n_chemical_formula_
structural Cs\n_chemical_formula_sum Cs1\n_cell_volume 114.04133631\n_cell_formula_uni
ts_Z 1\nloop_\n _symmetry_equiv_pos_site_id\n _symmetry_equiv_pos_as_xyz\n 1 'x, y, z'\n
loop_\n _atom_site_type_symbol\n _atom_site_label\n _atom_site_symmetry_multiplicity\n _atom
_site_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n _atom_site_occupancy\n Cs Cs1 1
0.000025 0.000006 0.999997 1\n"},
{'task_id': 'mp-2', 'icsd_ids': '64918, 648679, 52251, 180870, 648674, 77885, 64922, 64914,
648675, 648676, 41517, 64916, 180871, 64915, 648673, 426965, 64920, 76148, 648677, 648680',
'pretty_formula': 'Pd', 'e_above_hull': 0, 'band_gap': 0.0, 'volume': 15.490309950598192, 'd
ensity': 11.40807157509303, 'diel': 'None', 'cif': "# generated using pymatgen\ndata_Pd\n_sy
mmetry_space_group_name_H-M 'P 1'\n_cell_length_a 2.79806867\n_cell_length_b 2.7980686
7\n_cell_length_c 2.79806867\n_cell_angle_alpha 60.00000000\n_cell_angle_beta 60.00000
000\n_cell_angle_gamma 60.00000000\n_symmetry_Int_Tables_number 1\n_chemical_formula_str
uctural Pd\n_chemical_formula_sum Pd1\n_cell_volume 15.49030995\n_cell_formula_units_Z
1\nloop_\n _symmetry_equiv_pos_site_id\n _symmetry_equiv_pos_as_xyz\n 1 'x, y, z'\nloop
_\n _atom_site_type_symbol\n _atom_site_label\n _atom_site_symmetry_multiplicity\n _atom_sit
e_fract_x\n _atom_site_fract_y\n _atom_site_fract_z\n _atom_site_occupancy\n Pd Pd1 1 0.
000000 0.000000 0.000000 1\n"}
]
2) Run the following command:
mongoimport --db mp --collection mpall --type json --file data.json --jsonArray
'Database' 카테고리의 다른 글
rename-db.sh: a linux shell script for renaming a mysql db schema (0) | 2019.12.05 |
---|