I was wondering if there is a smarter way of doing the following code. Basically what is does is that it opens a data file with a lot of rows and columns. The columns are then sorted so each column is a vector with all the data inside.
"3.2.2 - Declare variables"
lineData = list()
for line in File:
splittedLine = line.split() # split
lineData.append(splittedLine) #collect
And here the fun begins
"3.2.3 - define desired variables from file"
col1 = "ElemNo"
col2 = "Node1"
col3 = "Node2"
col4 = "Length"
col5 = "Area"
col6 = "Inertia"
col7 = "Fnode1"
col8 = "Fnode2"
col9 = "SigmaMin"
col10 = "SigmaMax"
"3.2.3 - make each variable as a list/vector"
var ={col1:[], col2:[], col3:[], col4:[], col5:[], col6:[], col7:[], col8:[]
,col9:[],col10:[]}
"3.2.3 - take the values from each row in lineData and collect them into the correct variable"
for row in lineData:
var[col1] .append(float(row[0]) ) #[-] ElemNo
var[col2] .append(float(row[1]) ) #[-] Node1
var[col3] .append(float(row[2]) ) #[-] Node2
var[col4] .append(float(row[3]) ) #[mm] Length
var[col5] .append(float(row[4]) ) #[mm^2] Area
var[col6] .append(float(row[5])*10**6) #[mm^4] Inertia
var[col7] .append(float(row[6]) ) #[N] Fnode1
var[col8] .append(float(row[7]) ) #[N] Fnode2
var[col9] .append(float(row[8]) ) #[MPa] SigmaMin
var[col10].append(float(row[9]) ) #[MPa] SigmaMax
As you see this is a rather annoying way of making each row into a variable. Any suggestions?