(file_name)
return values
Parses the amc file format.
Parses the amc file format.
Parses the amc file format .
def parse(file_name):
  """Parses the amc file format."""
  values = []
  fid = open(file_name, 'r')
  line = fid.readline().strip()
  frame_ind = 1
  first_frame = True
  while True:
    # Parse first frame.
    if first_frame and line[0] == str(frame_ind):
      first_frame = False
      frame_ind += 1
      frame_vals = []
      while True:
        line = fid.readline().strip()
        if not line or line == str(frame_ind):
          values.append(np.array(frame_vals, dtype=np.float))
          break
        tokens = line.split()
        frame_vals.extend(tokens[1:])
    # Parse other frames.
    elif line == str(frame_ind):
      frame_ind += 1
      frame_vals = []
      while True:
        line = fid.readline().strip()
        if not line or line == str(frame_ind):
          values.append(np.array(frame_vals, dtype=np.float))
          break
        tokens = line.split()
        frame_vals.extend(tokens[1:])
    else:
      line = fid.readline().strip()
      if not line:
        break
  return values
def parse ( file_name ) : values = [ ] fid = open ( file_name , 'r' ) line = fid . readline ( ) . strip ( ) frame_ind = 1 first_frame = True while True : # Parse first frame. if first_frame and line [ 0 ] == str ( frame_ind ) : first_frame = False frame_ind += 1 frame_vals = [ ] while True : line = fid . readline ( ) . strip ( ) if not line or line == str ( frame_ind ) : values . append ( np . array ( frame_vals , dtype = np . float ) ) break tokens = line . split ( ) frame_vals . extend ( tokens [ 1 : ] ) # Parse other frames. elif line == str ( frame_ind ) : frame_ind += 1 frame_vals = [ ] while True : line = fid . readline ( ) . strip ( ) if not line or line == str ( frame_ind ) : values . append ( np . array ( frame_vals , dtype = np . float ) ) break tokens = line . split ( ) frame_vals . extend ( tokens [ 1 : ] ) else : line = fid . readline ( ) . strip ( ) if not line : break return values