- Author:
- finbar <farg967@aucklanduni.ac.nz>
- Date:
- 2021-08-28 17:51:51+12:00
- Desc:
- Added bond graph diagram of arterial system.
- Permanent Source URI:
- https://models.physiomeproject.org/workspace/673/rawfile/9c4778c86df9c284ec56d5bb1a5de179942f6bb2/io_flow_data_into_cellml.py
import pandas as pd
import re
data = pd.read_csv('df_vessels.csv')
with open('Parameters218.cellml', 'r') as r:
with open('Parameters218_new.cellml', 'w') as w:
for line in r:
for rowNum in range(data.shape[0]):
flow_name = 'v_nom_' + data.iloc[rowNum, 0]
flow_val = data.iloc[rowNum,3]
flow_val_string = 'initial_value=\"{:.8f}e-6\"'.format(flow_val)
if flow_name in line:
line = re.sub('initial_value=\"\d*\.?\d*e?-?\d*\"', flow_val_string, line)
break
w.write(line)