docstr: Collate and process collected character data
docstr_tok: ["Collate","and","process","collected","character","data"]
code: def flush_chardata(self):
      """Collate and process collected character data"""
      # Nothing to do for empty elements, except for Data elements which
      # are within a DataArray with an external file
      if self.write_to != "Data" and self._char_blocks is None:
          return
      # Just join the strings to get the data.  Maybe there are some memory
      # optimizations we could do by passing the list of strings to the
      # read_data_block function.
      if self._char_blocks is not None:
          data = "".join(self._char_blocks)
      else:
          data = None
      # Reset the char collector
      self._char_blocks = None
  
      # Process data
      if self.write_to == "Name":
          data = data.strip()
          self.nvpair[0] = data
  
      elif self.write_to == "Value":
          data = data.strip()
          self.nvpair[1] = data
  
      elif self.write_to == "DataSpace":
          data = data.strip()
          self.coordsys.dataspace = xform_codes.code[data]
  
      elif self.write_to == "TransformedSpace":
          data = data.strip()
          self.coordsys.xformspace = xform_codes.code[data]
  
      elif self.write_to == "MatrixData":
          # conversion to numpy array
          c = StringIO(data)
          self.coordsys.xform = np.loadtxt(c)
          c.close()
  
      elif self.write_to == "Data":
          self.da.data = read_data_block(
              self.da, self.fname, data, self.mmap
          )
          # update the endianness according to the
          # current machine setting
          self.endian = gifti_endian_codes.code[sys.byteorder]
  
      elif self.write_to == "Label":
          self.label.label = data.strip()
  
imports: import base64
  import os.path
  import sys
  import warnings
  import zlib
  from io import StringIO
  from xml.parsers.expat import ExpatError
  import numpy
  from ..nifti1 import data_type_codes, intent_codes, xform_codes
  from ..xmlutils import XmlParser
  from .gifti import GiftiCoordSystem, GiftiDataArray, GiftiImage, GiftiLabel, GiftiLabelTable, GiftiMetaData
  from .util import array_index_order_codes, gifti_encoding_codes, gifti_endian_codes
label_desc: Use image node_id 5 for calling the GiftiImageParser obj's underlying member method code with example usage: obj.flush_chardata() without return types