docs: def _valuePivot(self, session, mapTable, contaminant, replaceParaFile):
          """
          This function retrieves the values of a mapping table from the database and pivots them into the format that is
          required by the mapping table file. This function returns a list of strings that can be printed to the file
          directly.
          """
          # Retrieve the indices for the current mapping table and mapping table file
          indexes = session.query(MTIndex). \
              join(MTValue.index). \
              filter(MTValue.mapTable == mapTable). \
              filter(MTValue.contaminant == contaminant). \
              order_by(MTIndex.index). \
              all()
  
          # determine number of layers
          layer_indices = [0]
          if mapTable.name in ('MULTI_LAYER_SOIL', 'RICHARDS_EQN_INFILTRATION_BROOKS'):
              layer_indices = range(3)
  
          # ----------------------------------------
          # Construct each line in the mapping table
          #-----------------------------------------
  
          # All lines will be compiled into this list
          lines = []
          values = {}
          for idx in indexes:
              for layer_index in layer_indices:
                  # Retrieve values for the current index
                  values = session.query(MTValue). \
                           filter(MTValue.mapTable == mapTable). \
                           filter(MTValue.contaminant == contaminant). \
                           filter(MTValue.index == idx). \
                           filter(MTValue.layer_id == layer_index). \
                           order_by(MTValue.id). \
                           all()
  
                  # NOTE: The second order_by modifier in the query above handles the special ordering of XSEDIMENT columns
                  # in soil erosion properties table (i.e. these columns must be in the same order as the sediments in the
                  # sediments table. Accomplished by using the sedimentID field). Similarly, the contaminant filter is only
                  # used in the case of the contaminant transport table. Values that don't belong to a contaminant will have
                  # a contaminant attribute equal to None. Compare usage of this function by _writeMapTable and
                  # _writeContaminant.
  
                  #Value string
                  valString = ''
  
                  # Define valString
                  for val in values:
                      if val.value <= -9999:
                          continue
                      # Format value with trailing zeros up to 6 digits
                      processedValue = vwp(val.value, replaceParaFile)
                      try:
                          numString = '%.6f' % processedValue
                      except:
                          numString = '%s' % processedValue
  
                      valString = '%s%s%s' % (valString, numString, ' ' * 3)
  
                  # Determine spacing for aesthetics (so each column lines up)
                  spacing1 = max(1, 6 - len(str(idx.index)))
                  spacing2 = max(1, 40 - len(idx.description1))
                  spacing3 = max(1, 40 - len(idx.description2))
  
                  # Compile each mapping table line
                  if layer_index == 0:
                      line = '%s%s%s%s%s%s%s\n' % (
                          idx.index, ' ' * spacing1, idx.description1, ' ' * spacing2, idx.description2, ' ' * spacing3, valString)
                  else:
                      num_prepend_spaces = len(str(idx.index)) + spacing1 + len(idx.description1) \
                                           + spacing2 + len(idx.description2) + spacing3
                      line = '{0}{1}\n'.format(' ' * num_prepend_spaces, valString)
  
                  # Compile each lines into a list
                  lines.append(line)
  
          #-----------------------------
          # Define the value header line
          #-----------------------------
  
          # Define varString for the header line
          varString = ''
  
          # Compile list of variables (from MTValue object list) into a single string of variables
          for idx, val in enumerate(values):
              if val.variable == 'XSEDIMENT':  # Special case for XSEDIMENT variable
                  if idx >= len(values) - 1:
                      varString = '%s%s%s%s' % (varString, mapTable.numSed, ' SEDIMENTS....', ' ' * 2)
              else:
                  varString = '%s%s%s' % (varString, val.variable, ' ' * 2)
  
          # Compile the mapping table header
          header = 'ID%sDESCRIPTION1%sDESCRIPTION2%s%s\n' % (' ' * 4, ' ' * 28, ' ' * 28, varString)
  
          # Prepend the header line to the list of lines
          lines.insert(0, header)
  
          # Return the list of lines
          return lines