docs: def formatted_str(self, format):
          """Return formatted str.
  
          :param format: one of 'json', 'csv' are supported
          """
          assert(format in ('json', 'csv'))
          ret_str_list = []
          for rec in self._records:
              if format == 'json':
                  ret_str_list.append('{')
                  for i in xrange(len(rec)):
                      colname, colval = self._rdef[i].name, rec[i]
                      ret_str_list.append('"%s":"%s"' % (colname, str(colval).replace('"', r'\"')))
                      ret_str_list.append(',')
                  ret_str_list.pop()  # drop last comma
                  ret_str_list.append('}%s' % (os.linesep))
              elif format == 'csv':
                  for i in xrange(len(rec)):
                      colval = rec[i]
                      ret_str_list.append('"%s"' % (str(colval).replace('"', r'\"')))
                      ret_str_list.append(',')
                  ret_str_list.pop()  # drop last comma
                  ret_str_list.append('%s' % (os.linesep))
              else:
                  assert(False)
          return ''.join(ret_str_list)