Skip to content
Snippets Groups Projects
Commit b68b2642 authored by Sebastian Kerger's avatar Sebastian Kerger
Browse files

Upload New File

parent 37c0f2c1
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# For the parameters specified in param_specs, fetches current values from the project sqlite db
Compares values with default to help with finding unit conversion factors
%% Cell type:code id: tags:
``` python3
import sqlite3
import pandas as pd
```
%% Cell type:code id: tags:
``` python3
# define the path of the parameter_config.xlsx
param_specs = pd.read_excel(R"path\parameter_config.xlsx")
param_specs
```
%% Cell type:code id: tags:
``` python3
# connect to sqlite of model
conn = sqlite3.connect(
R"path\example_model.sqlite"
)
cur = conn.cursor()
for i in param_specs.index:
tab = param_specs.loc[i, "Table"]
col = param_specs.loc[i, "Column"]
muid = param_specs.loc[i, "Muid"]
try:
dbrs = cur.execute(
f'SELECT {col.lower()} FROM {tab.lower()} WHERE muid="{muid}"'
).fetchall()[0][0]
print(dbrs)
except Exception as e:
print(e)
dbrs = str(e)
assert dbrs != None
param_specs.loc[i, "DBDefault"] = dbrs
conn.close()
```
%% Cell type:code id: tags:
``` python3
param_specs
```
%% Cell type:code id: tags:
``` python3
param_specs["UnitFactor"]=param_specs["DBDefault"]/param_specs["_UnitDefault"]
```
%% Cell type:code id: tags:
``` python3
param_specs["UnitFactor"]
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment