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