On 06/02/2019 21:45, Mark Lawrence wrote:

So what, you still don't need to chop the front from the list, just process the data.

just slice


I'd like to adapt the order in that the functions are applied, but how?

I suspect that you're trying to over complicate things, what's wrong with a simple if/elif chain, a switch based on a dict or similar?


You mean create a list with the order=[a,b,e,d...]
Again I've no idea what you're saying here.

depending on how the input file is created data packet a can be in an other position for every line.
figured out how to do it though

order=[a,b,e,d...]
for i in lines:
  i=i.split(" ")
    for j in order:
      if j = a:
        use function for processing data chunk a
      elseif j = b:
        use proper function for processing data type b
      ...

I don't know beforehand how many lines I have.

Now you tell us :-(

sorry

then loop order=[a,b,e,d...] for each line


What has a loop order got to do with using a dict?

order of data chunks varies per file

Why bother, just have a list of lists and index on the position, or are we talking at cross purposes?

Sorry for the amount of text below, I hope it clarifies
one line of space delimited input data:

0 1094.82 0.1 582.419 0.5 14 (0.200231,1.13714,-8.35338) (-10.2097,1.13714,-4.05001) (-10.2097,-14.3466,-4.05001) (-2.4419,-39.895,9.65513) (-0.382375,-100.1,7.27361) (0.200231,-100.1,-8.35338) (-2.43137,1.58294,9.64296) (-10.1818,1.514,-4.00085) (-2.4419,1.51399,9.65513) (3.73705,-100.1,2.51013) (0.220825,1.58294,-8.29013) (-6.42082,-100.1,-5.61629) (-10.1626,1.58294,-3.9977) (3.73705,1.58294,2.51013) (1095.02,1.23714,574.066) (1084.61,1.23714,578.369) (1084.61,-14.2466,578.369) (1092.38,-39.795,592.074) (1094.44,-100,589.693) (1095.02,-100,574.066) (1092.39,1.68294,592.062) (1084.64,1.614,578.418) (1092.38,1.61399,592.074) (1098.56,-100,584.929) (1095.04,1.68294,574.129) (1088.4,-100,576.803) (1084.66,1.68294,578.421) (1098.56,1.68294,584.929) 3 3 3 3 3 3 3 3 3 3 3 3 3 3 10092.8 21 550.726 9 23.4034 221.001 102.986 190.388 219.178 39.1211 226.154 47.7032 31.5186 4765.01 5 5 5 4 6 4 5 4 4 0 0 0 0 4 4 1 5.07336 964.581 451.085 1100.75 865.736 81.7357 1161.69 133.262 1.10745 (1,0,10,12,7) (1,2,11,5,0) (1,7,8,3,2) (2,3,4,11) (3,8,6,13,9,4) (4,9,5,11) (5,9,13,10,0) (6,12,10,13) (6,8,7,12) (-0.377877,0.147157,-0.914086) (-0.382036,2.8913e-18,-0.924147) (-0.869981,0,0.493086) (-0.904528,-0.0477043,0.423738) (0.75639,-5.72053e-15,0.654121) (-0,-1,0) (0.950875,4.0561e-18,-0.309575) (-5.99268e-17,1,-1.44963e-16) (-0.849681,0.21476,0.481581) 9205 9105 3062 9946 5786 -3 1483 100 3262 11680.5 -2.00777 -44.9048 -0.428504 1092.81 -44.8048 581.99

this one line as it is in the output file. For a file with 100000 lines the outer arrays will be 100000 items long:

#declare Labels = array[0]{0}
#declare Points = array[0]{<1094.82,0.1,582.419>}
#declare Radii = array[0]{0.5}
#declare NumVertices = array[0]{14}
#declare RelVertices = array[0]{
  //label: 0
  array[14]{

<0.200231,1.13714,-8.35338>,<-10.2097,1.13714,-4.05001>,<-10.2097,-14.3466,-4.05001>,<-2.4419,-39.895,9.65513>,<-0.382375,-100.1,7.27361>,<0.200231,-100.1,-8.35338>,<-2.43137,1.58294,9.64296>,<-10.1818,1.514,-4.00085>,<-2.4419,1.51399,9.65513>,<3.73705,-100.1,2.51013>,<0.220825,1.58294,-8.29013>,<-6.42082,-100.1,-5.61629>,<-10.1626,1.58294,-3.9977>,<3.73705,1.58294,2.51013>
  }
}
#declare GlobalVertices = array[0]{
  //label: 0
  array[14]{

<1095.02,1.23714,574.066>,<1084.61,1.23714,578.369>,<1084.61,-14.2466,578.369>,<1092.38,-39.795,592.074>,<1094.44,-100,589.693>,<1095.02,-100,574.066>,<1092.39,1.68294,592.062>,<1084.64,1.614,578.418>,<1092.38,1.61399,592.074>,<1098.56,-100,584.929>,<1095.04,1.68294,574.129>,<1088.4,-100,576.803>,<1084.66,1.68294,578.421>,<1098.56,1.68294,584.929>
  }
}
#declare MaxRadius = array[0]{10092.8}
#declare NumEdges = array[0]{21}
#declare EdgeDistance = array[0]{550.726}
#declare NumFaces = array[0]{9}
#declare FacePerimeter = array[0]{
  //label: 0

array[9]{23.4034,221.001,102.986,190.388,219.178,39.1211,226.154,47.7032,31.5186}
}
#declare SurfaceArea = array[0]{4765.01}
#declare FacesOrders = array[0]{
  //label: 0
  array[9]{5,5,5,4,6,4,5,4,4}
}
#declare FreqFaces = array[0]{
  //label: 0
  array[7]{0,0,0,0,4,4,1}
}
#declare FaceArea = array[0]{
  //label: 0

array[9]{5.07336,964.581,451.085,1100.75,865.736,81.7357,1161.69,133.262,1.10745}
}
#declare FaceVerticesIndex = array[0]{
  //label: 0
  array[9]{
    array[5]{1,0,10,12,7},
    array[5]{1,2,11,5,0},
    array[5]{1,7,8,3,2},
    array[4]{2,3,4,11},
    array[6]{3,8,6,13,9,4},
    array[4]{4,9,5,11},
    array[5]{5,9,13,10,0},
    array[4]{6,12,10,13},
    array[4]{6,8,7,12},
  }
}
#declare FaceNormal = array[0]{
  //label: 0
  array[9]{

<-0.377877,0.147157,-0.914086>,<-0.382036,2.8913e-18,-0.924147>,<-0.869981,0,0.493086>,<-0.904528,-0.0477043,0.423738>,<0.75639,-5.72053e-15,0.654121>,<-0,-1,0>,<0.950875,4.0561e-18,-0.309575>,<-5.99268e-17,1,-1.44963e-16>,<-0.849681,0.21476,0.481581>
  }
}
#declare Neighbours = array[0]{
  //label: 0
  array[9]{9205,9105,3062,9946,5786,-3,1483,100,3262},
}
#declare Volume = array[0]{11680.5}
#declare RelCentroid = array[0]{<-2.00777,-44.9048,-0.428504>}
#declare GlobalCentroid = array[0]{<1092.81,-44.8048,581.99>}

ingo
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to