MIDSX 0.1
A x-ray transport code system for dosimetry
Loading...
Searching...
No Matches
gen_materials_page.py
1import sqlite3
2import pandas as pd
3import os
4
5# Change working directory to the directory of this file
6os.chdir(os.path.dirname(os.path.abspath(__file__)))
7
8db_path = '../../data/data_sources/EPDL/midsx.db'
9conn = sqlite3.connect(db_path)
10c = conn.cursor()
11
12# Export Materials table to pandas dataframe
13df = pd.read_sql_query("SELECT * FROM Materials", conn)
14
15# Add units to density column name
16df.rename(columns={'Density': 'Density (g/cm3)'}, inplace=True)
17
18# Export df to markdown
19df.to_markdown('Materials.md', index=False)
20
21header = "# Materials Available For Simulation"
22
23# Add header to markdown file
24with open('Materials.md', 'r+') as f:
25 content = f.read()
26 f.seek(0, 0)
27 f.write(header + '\n' + content)
28