Adds CSV fields which aren't part of the Aspire user profile JSON API
 @param row [Array] the fields from the All User Profiles report CSV
 @param data [Hash] the JSON representation of the user profile
 @return [Hash] the JSON data hash
427196
def csv_to_json_other(row, data = {})
      # The following fields are not present in the JSON API response but are in
      # the All User Profiles report - they are included for completeness.
      data['jobRole'] = row[5] || ''
      data['lastLogin'] = row[8]
      data['name'] = row[2] || ''
      data['visibility'] = row[6] || ''
      data
    end
422352
def <<(row)
      if row == Border::SEPARATOR
        separators << columns_size - (header ? 0 : 2)
      else
        rows_copy = rows.dup
        assert_row_sizes rows_copy << row
        rows << to_row(row)
      end
      self
    end
148582
def field_csv(*include_fields)
      fields = field_report.keys
      fields.select! { |f| include_fields.include? f } unless
        include_fields.empty?

      variables = [:value, :aggregation, :isShownAt]
      headers = fields.product(variables).map { |header| header.join(' ') }

      table = CSV::Table.new([CSV::Row.new(headers, [], true)])
      return table if field_report.nil? || field_report.empty?

      rows = []

      field_report.each do |field, values|
        values.each do |value, agg_list|
          agg_list.each_with_index do |agg_hash, i|
            rows[i] ||= CSV::Row.new(headers, [])
            rows[i]["#{field} value"] = value.to_s
            rows[i]["#{field} aggregation"] = agg_hash[:aggregation].to_s
            rows[i]["#{field} isShownAt"] = agg_hash[:isShownAt].to_s
          end
        end
      end

      rows.each { |r| table << r }
      table
    end
90824
def parse_results(fields, data):
    
    master = []

    for record in data['records']:  # for each 'record' in response
        row = [None] * len(fields)  # create null list the length of number of columns
        for obj, value in record.iteritems():  # for each obj in record
            if not isinstance(value, (dict, list, tuple)):  # if not data structure
                if obj in fields:
                    row[fields.index(obj)] = ensure_utf(value)

            elif isinstance(value, dict) and obj != 'attributes':  # traverse down into object
                path = obj
                _traverse_results(value, fields, row, path)

        master.append(row)
    return master
602516
def ParseRow(header,
             row):
  
  precondition.AssertDictType(row, Text, Text)

  result = rdf_osquery.OsqueryRow()
  for column in header.columns:
    result.values.append(row[column.name])
  return result
212739
def to_json(*args)
      rows = []
      self.each_row do |row|
        rows.push(row.to_hash)
      end
      rows.to_json
    end
1052561
def csv_format(csv_data, c_headers=None, r_headers=None, rows=None, **kwargs):
    
    result = None
    c_headers = [] if c_headers is None else c_headers
    r_headers = [] if r_headers is None else r_headers
    rows = [] if rows is None else rows

    result_format = kwargs.get('result_format', ARRAY_RAW_FORMAT)

    # DICT FORMAT
    if result_format == DICT_FORMAT:
        result = csv_dict_format(csv_data, c_headers, r_headers)

    # ARRAY_RAW_FORMAT
    elif result_format == ARRAY_RAW_FORMAT:
        result = rows

    # ARRAY_CLEAN_FORMAT
    elif result_format == ARRAY_CLEAN_FORMAT:
        result = csv_array_clean_format(csv_data, c_headers, r_headers)

    else:
        result = None

    # DEFAULT
    if result and result_format < DICT_FORMAT:
        result = [result]

    return result
741932
def addRow(self, *row):
        
        row     = [ str(item) for item in row ]
        len_row = [ len(item) for item in row ]
        width   = self.__width
        len_old = len(width)
        len_new = len(row)
        known   = min(len_old, len_new)
        missing = len_new - len_old
        if missing > 0:
            width.extend( len_row[ -missing : ] )
        elif missing < 0:
            len_row.extend( [0] * (-missing) )
        self.__width = [ max( width[i], len_row[i] ) for i in compat.xrange(len(len_row)) ]
        self.__cols.append(row)
455641
public void addRow(String[] data) {

        if (data.length != iColCount) {
            return;
        }

        String[] row = new String[iColCount];

        for (int i = 0; i < iColCount; i++) {
            row[i] = data[i];

            if (row[i] == null) {
                row[i] = "(null)";
            }
        }

        vData.addElement(row);

        iRowCount++;
    }
682391
def add_row(self, obj):
        
        row = {}
        for column in self.headers:

            value = ''

            if '__col__' in column:
                if isinstance(column['__col__'], ColumnProperty):
                    value = self._get_column_cell_val(obj, column)

                elif isinstance(column['__col__'], RelationshipProperty):
                    value = self._get_relationship_cell_val(obj, column)

            row[column['name']] = value

        self._datas.append(self.format_row(row))
755558
def get_csv_col_headers(rows, row_headers_count_value=0):
    
    count = 0

    if rows:
        for row in rows:
            if exclude_empty_values(row[:row_headers_count_value]):
                break
            count += 1

    if len(rows) == count:
        count = 1  # by default

    return [r[row_headers_count_value:] for r in rows[:count]]
460327
def rows_to_columns(data, schema=None):
    
    if not schema:
        schema = SchemaTree()
    all_schema = schema
    all_leaves = schema.leaves
    values = {full_name: [] for full_name in all_leaves}
    reps = {full_name: [] for full_name in all_leaves}
    defs = {full_name: [] for full_name in all_leaves}

    def _none_to_column(schema, path, rep_level, def_level):
        for full_path in all_schema.leaves:
            if startswith_field(full_path, path):
                reps[full_path].append(rep_level)
                defs[full_path].append(def_level)

    def _value_to_column(value, schema, path, counters, def_level):
        ptype = type(value)
        ntype, dtype, ltype, jtype, itype, byte_width = python_type_to_all_types[ptype]

        if jtype is NESTED:
            if schema.element.repetition_type != REPEATED:
                Log.error("Expecting {{path|quote}} to be repeated", path=path)

            new_path = path
            if not value:
                _none_to_column(schema, new_path, get_rep_level(counters), def_level)
            else:
                try:
                    new_schema = schema.more.get('.')

                    if not new_schema:
                        if schema.locked:
                            # DEFAULT TO REQUIRED ENTRIES
                            new_schema = schema
                            schema.element.repetition_type = REQUIRED
                        else:
                            new_path = path
                            new_value = value[0]
                            ptype = type(new_value)
                            new_schema = schema.add(
                                new_path,
                                OPTIONAL,
                                ptype
                            )
                            if new_value is None or python_type_to_json_type[ptype] in PRIMITIVE:
                                values[new_path] = []
                                reps[new_path] = [0] * counters[0]
                                defs[new_path] = [0] * counters[0]
                    for k, new_value in enumerate(value):
                        new_counters = counters + (k,)
                        _value_to_column(new_value, new_schema, new_path, new_counters, def_level+1)
                finally:
                    schema.element.repetition_type = REPEATED
        elif jtype is OBJECT:
            if value is None:
                if schema.element.repetition_type == REQUIRED:
                    Log.error("{{path|quote}} is required", path=path)
                _none_to_column(schema, path, get_rep_level(counters), def_level)
            else:
                if schema.element.repetition_type == REPEATED:
                    Log.error("Expecting {{path|quote}} to be repeated", path=path)

                if schema.element.repetition_type == REQUIRED:
                    new_def_level = def_level
                else:
                    counters = counters + (0,)
                    new_def_level = def_level+1

                for name, sub_schema in schema.more.items():
                    new_path = concat_field(path, name)
                    new_value = value.get(name, None)
                    _value_to_column(new_value, sub_schema, new_path, counters, new_def_level)

                for name in set(value.keys()) - set(schema.more.keys()):
                    if schema.locked:
                        Log.error("{{path}} is not allowed in the schema", path=path)
                    new_path = concat_field(path, name)
                    new_value = value.get(name, None)
                    ptype = type(new_value)
                    sub_schema = schema.add(
                        new_path,
                        REPEATED if isinstance(new_value, list) else OPTIONAL,
                        ptype
                    )
                    if python_type_to_json_type[ptype] in PRIMITIVE:
                        values[new_path] = []
                        reps[new_path] = [0] * counters[0]
                        defs[new_path] = [0] * counters[0]
                    _value_to_column(new_value, sub_schema, new_path, counters, new_def_level)
        else:
            if jtype is STRING:
                value = value.encode('utf8')
            merge_schema(schema, path, value)
            values[path].append(value)
            if schema.element.repetition_type == REQUIRED:
                reps[path].append(get_rep_level(counters))
                defs[path].append(def_level)
            else:
                reps[path].append(get_rep_level(counters))
                defs[path].append(def_level + 1)

    for rownum, new_value in enumerate(data):
        try:
            _value_to_column(new_value, schema, '.', (rownum,), 0)
        except Exception as e:
            Log.error("can not encode {{row|json}}", row=new_value, cause=e)

    return Table(values, reps, defs, len(data), schema)
67958
def insert_row(row_index = 0)
      validate_workbook
      ensure_cell_exists(row_index)

      old_row = new_cells = nil

      if row_index > 0 then
        old_row = sheet_data.rows[row_index - 1]
        if old_row then
          new_cells = old_row.cells.collect { |c|
                        if c.nil? then nil
                        else nc = RubyXL::Cell.new(:style_index => c.style_index)
                             nc.worksheet = self
                             nc
                        end
                      }
        end
      end

      row0 = sheet_data.rows[0]
      new_cells ||= Array.new((row0 && row0.cells.size) || 0)

      sheet_data.rows.insert(row_index, nil)
      new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)

      # Update row values for all rows below
      row_index.upto(sheet_data.rows.size - 1) { |r|
        row = sheet_data.rows[r]
        next if row.nil?
        row.cells.each_with_index { |cell, c|
          next if cell.nil?
          cell.r = RubyXL::Reference.new(r, c)
        }
      }

      return new_row
    end
1269183
def headers(row = nil)
      row ||= rows.first
      header_type = row.th.exist? ? 'th' : 'td'
      row.send("#{header_type}s")
    end
521943
def rows_generator include_meta_data=false, use_simple_rows_format=false
      path = if @sheetfile.start_with? "/xl/" or @sheetfile.start_with? "xl/" then @sheetfile else "xl/#{@sheetfile}" end
      if @book.files.file.exist?(path)
        # SAX parsing, Each element in the stream comes through as two events:
        # one to open the element and one to close it.
        opener = Nokogiri::XML::Reader::TYPE_ELEMENT
        closer = Nokogiri::XML::Reader::TYPE_END_ELEMENT
        Enumerator.new do |y|
          row, cells, cell = nil, {}, nil
          cell_type  = nil
          cell_style_idx = nil
          @book.files.file.open(path) do |xml|
            Nokogiri::XML::Reader.from_io(xml).each do |node|
              if (node.name.eql? 'row') and (node.node_type.eql? opener)
                row = node.attributes
                row['cells'] = Hash.new
                cells = Hash.new
                y << (include_meta_data ? row : cells) if node.self_closing?
              elsif (node.name.eql? 'row') and (node.node_type.eql? closer)
                processed_cells = fill_in_empty_cells(cells, row['r'], cell, use_simple_rows_format)

                if @images_present
                  processed_cells.each do |cell_name, cell_value|
                    next unless cell_value.nil?
                    processed_cells[cell_name] = images_at(cell_name)
                  end
                end

                row['cells'] = processed_cells
                y << (include_meta_data ? row : processed_cells)
              elsif (node.name.eql? 'c') and (node.node_type.eql? opener)
                cell_type      = node.attributes['t']
                cell_style_idx = node.attributes['s']
                cell           = node.attributes['r']
              elsif (['v', 't'].include? node.name) and (node.node_type.eql? opener)
                unless cell.nil?
                  node.read
                  cells[(use_simple_rows_format ? cell.tr("0-9", "") : cell)] = convert(node.value, cell_type, cell_style_idx)
                end
              end
            end
          end
        end
      end
    end
981521
def parse_row(line_num, line, header, column_idx, prev_fields, options)
      fields = LineParser::parse(line, options[:in_format], options[:split_on])
      return nil,nil if fields.compact == []
      if options[:pad_fields] and fields.size < header.size
        fields += [''] * (header.size - fields.size) 
      end
      fields = Formatter::strip_quotes(fields) if @strip_quotes
      fields = Formatter::transform_row_ids(@transform_ids, fields) if @transform_ids
      fields = Filter::apply_column_filter(fields,column_idx) 
      return nil,nil if fields.compact == []
      rowname = fields[0]
      data_fields = fields[@first_column..-1]
      if data_fields.size > 0
        return nil,nil if not Validator::valid_row?(line_num, data_fields, prev_fields)
        return nil,nil if not Filter::numeric(@num_filter,data_fields,header)
        return nil,nil if not Filter::generic(@filter,data_fields,header)
        (rowname, data_fields) = Rewrite::rewrite(@rewrite,rowname,data_fields)
      end
      return rowname, data_fields
    end
1246102
public static Row project(Row row, int[] fields) {
		final Row newRow = new Row(fields.length);
		for (int i = 0; i < fields.length; i++) {
			newRow.fields[i] = row.fields[fields[i]];
		}
		return newRow;
	}