code: def _parse_bands(lines, n_start):
          
          kpoints = []
          labels = []
          bands_s1 = []
          bands_s2 = []
          known_kpoints = {}
          pattern = re.compile(".*?Nr.*?Spin.*?K-Point.*?", re.DOTALL)
  
          selected_lines = lines[n_start:]
          for current_line, line in enumerate(selected_lines):
              splitted = line.split()
              if "KPOINTS| Special K-Point" in line:
                  kpoint = tuple(map(float, splitted[-3:]))
                  if " ".join(splitted[-5:-3]) != "not specified":
                      label = splitted[-4]
                      known_kpoints[kpoint] = label
              elif pattern.match(line):
                  spin = int(splitted[3])
                  kpoint = tuple(map(float, splitted[-3:]))
                  kpoint_n_lines = int(math.ceil(int(selected_lines[current_line + 1]) / 4.))
                  band = list(
                      map(float, ' '.join(selected_lines[current_line + 2:current_line + 2 + kpoint_n_lines]).split()))
                  if spin == 1:
                      if kpoint in known_kpoints:
                          labels.append((len(kpoints), known_kpoints[kpoint]))
                      kpoints.append(kpoint)
                      bands_s1.append(band)
                  elif spin == 2:
                      bands_s2.append(band)
          if bands_s2:
              bands = [bands_s1, bands_s2]
          else:
              bands = bands_s1
          return np.array(kpoints), labels, np.array(bands)
docs: Parse band structure from cp2k output