code: def getNumberOfTokens(networkDataFile):
      
      try:
        with open(networkDataFile) as f:
          reader = csv.reader(f)
          next(reader, None)
          next(reader, None)
          resetIdx = next(reader).index("R")
  
          count = 0
          numTokens = []
          for line in reader:
            if int(line[resetIdx]) == 1:
              if count != 0:
                numTokens.append(count)
              count = 1
            else:
              count += 1
          numTokens.append(count)
          return numTokens
  
      except IOError as e:
        print "Could not open the file {}.".format(networkDataFile)
        raise e
docs: Returns the number of tokens for each sequence
      @param networkDataFile  (str)     Path to file in the FileRecordStream
                                        format
      @return                 (list)    list of number of tokens