I have the folowing input CSV file:
prefix_files = 'wave6results_'
op2file= 'TRAM.op2'
fmin= 11
fmax= 20
df= 3.0
bemsurface= ['PCOMP PID_260002', 'PCOMP PID_260003', 'PCOMP PID_260004', 'PCOMP PID_260005', 'PCOMP PID_260006', 'PCOMP PID_260016', 'PCOMP PID_260026']
meshsize= 0.07
areathreshold= 0.02
dafspectra= [134.7, 138.2, 142.0, 140.6, 135.1, 129.0, 124.5, 120.7, 117.7, 0]
dlf= [0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02]
output_acc= 1
name_acc= ['Capteurs Coque', 'Capteurs Backing Structure']
ranges_acc= [[100000, 100999],[600000, 600999]]
output_force= 1
name_force= ['SPC set10']
output_cons= 1
name_cons= 'FePID'
FePID_cons= [260002, 260003, 260004, 260005, 260006, 260016, 260026, 460006, 464800, 464801, 466200, 470006, 474800, 474801, 476200, 480000, 480001, 480200, 480240, 490300, 496301, 527001, 527002, 600300, 610000, 620200, 620350, 620550, 630200, 700800, 800000, 800001, 820000, 821000]
As you can guess, I want to pass them into my Python script such that, for example, the variable bemsurface is a list composed of all the 'PCOMP PID...' you see in the first line of my CSV extract.
I believe the easiest way to get those variables is going through pandas, so I coded something like:
from pathlib import Path
import pandas as pd
path_csv = Path('CreateModel_input_test.csv')
input_values = pd.read_csv(path_csv, names = ['variables','values'], delimiter='=')
This gives me a nice dataframe with, on one column the names of the variables I want and on the other column their values.
1 2
0 prefix_files 'wave6results_'
1 op2file 'TRAM.op2'
2 fmin 11
3 fmax 20
4 df 3.0
5 bemsurface ["PCOMP PID_260002", "PCOMP PID_260003", "PCOMP PID_260004", "PCOMP PID_260005", "PCOMP PID_260006", "PCOMP PID_260016", "PCOMP PID_260026"]
6 meshsize 0.07
Now I know the eval() function is to be avoided at all cost, so how would you go through the dataframe and assign the values on the right to variables named from the left column?
Thank you in advance for your help :)