-
Notifications
You must be signed in to change notification settings - Fork 0
/
yaml_excel.py
26 lines (22 loc) · 904 Bytes
/
yaml_excel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Author: Rafshan Ul Atik
# Date: Feb 2023
# Email: rafshanulatik@gmail.com
#
import yaml
import pandas as pd
# Read the YAML file
with open('thermal_properties.yaml', 'r') as stream:
data = yaml.safe_load(stream)
# Create an empty dataframe
df = pd.DataFrame(columns=['Temperature (K)', 'Free Energy (kJ/mol)', 'Entropy (J/K/mol)', 'Heat Capacity (J/K/mol)', 'Energy (kJ/mol)'])
# Loop through the thermal properties and append to the dataframe
for item in data['thermal_properties']:
df = df.append({
'Temperature (K)': item['temperature'],
'Free Energy (kJ/mol)': item['free_energy'],
'Entropy (J/K/mol)': item['entropy'],
'Heat Capacity (J/K/mol)': item['heat_capacity'],
'Energy (kJ/mol)': item['energy']
}, ignore_index=True)
# Save the dataframe to an Excel file
df.to_excel('thermal_properties.xlsx', index=False)