Ive got a code which processes a load of files and turns the output into a single matlab file.
In this code I now want it to record the length (how many rows) are in each of my 900,000 files, and create a new variable with these values in and then save the output to another matlab file.
I have tried writing this in, but when I run this it does not produce the numbers I expect. Can anybody help?
In this code I now want it to record the length (how many rows) are in each of my 900,000 files, and create a new variable with these values in and then save the output to another matlab file.
I have tried writing this in, but when I run this it does not produce the numbers I expect. Can anybody help?
import inspect c = 0 out = {} starts = 0 ends = 900000 vel = np.zeros([ends-starts,3]) points = np.zeros([ends-starts,3]) l = np.zeros([ends-starts,1]) for i in range(starts,ends): # File to read fname = 'RP_DATA_%04.0f.vtp'%i # --- read a vtp file --- points = vtk.vtkXMLPolyDataReader() points.SetFileName(fname) points.Update() # print the arrays out data = points.GetOutput() point_data = data.GetPointData() # print(inspect.getdoc(point_data)) l[c,:] = len('data') vel[c,:] = np.mean(vtk_to_numpy(point_data.GetAbstractArray('Velocity')),axis=0) # points[c,:] = vtk_to_numpy(data.GetPoints().GetData()) c = c+1; print(c/ends) name = "F01_C05.mat" sio.savemat(name, {'vel':vel}) n = "length.mat" sio.savemat(n, {'l':l})
Larz60+ write Aug-23-2021, 05:09 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.