Add header line with field names as CSV line
163923
protected function addHeaderRowToCSV()
    {
        $fieldArray = array_combine($this->fieldArray, $this->fieldArray);
        $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvHeader'] ?? [];
        if (!empty($hooks)) {
            $hookParameters = [
                'fields' => &$fieldArray,
            ];
            foreach ($hooks as $hookFunction) {
                GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
            }
        }
        // Add header row, control fields will be reduced inside addToCSV()
        $this->addToCSV($fieldArray);
    }
973397
def __put_names_on_csv_cols(names, cols):
        
        _combined = {}
        for idx, name in enumerate(names):
            # Use the variableName, and the column data from the same index
            _combined[name] = cols[idx]



        return _combined
83845
public boolean addCSV(HttpHeader header, String... values) {
        QuotedCSV existing = null;
        for (HttpField f : this) {
            if (f.getHeader() == header) {
                if (existing == null)
                    existing = new QuotedCSV(false);
                existing.addValue(f.getValue());
            }
        }

        String value = addCSV(existing, values);
        if (value != null) {
            add(header, value);
            return true;
        }
        return false;
    }
372439
private List<String> getFieldListFromHeader(BufferedReader reader) {
        // Read the first line and watch out for BOM at the front of the header.
        String header = null;
        try {
            header = reader.readLine();
        } catch (IOException e) {
            // Leave header null
        }
        if (Utils.isEmpty(header)) {
            logErrorThrow("No header found in file");
        }
        if (header.charAt(0) == '\uFEFF') {
            header = header.substring(1);
        }
        
        // Split around commas, though this will include spaces.
        String[] tokens = header.split(",");
        List<String> result = new ArrayList<String>();
        for (String token : tokens) {
            // If this field matches the _ID field, add it with that name.
            String fieldName = token.trim();
            if (fieldName.equals(m_config.id)) {
                result.add(CommonDefs.ID_FIELD);
            } else {
                result.add(token.trim());
            }
        }
        return result;
    }
166381
function serializeHeaders(mHeaders) {
		var sHeaderName,
			aHeaders = [];

		for (sHeaderName in mHeaders) {
			aHeaders = aHeaders.concat(sHeaderName, ":", mHeaders[sHeaderName], "\r\n");
		}

		return aHeaders;
	}
1080297
def write_tsv(headerfields, features, outfn):
    
    with open(outfn, 'w') as fp:
        write_tsv_line_from_list(headerfields, fp)
        for line in features:
            write_tsv_line_from_list([str(line[field]) for field
                                      in headerfields], fp)
1160084
def as_csv(self):
        """"""

        from io import StringIO

        s = StringIO()
        w = csv.writer(s)
        for row in self.rows:
            w.writerow(row)

        return s.getvalue()
745809
def get_csv_header(fname, sep=','):
    
    with open(fname, encoding='utf-8-sig') as f:
        return next(f).split(sep)
504943
function toCSVString(data, params) {
    if (data.length === 0) {
      return '';
    }
    params = params || {};

    var header = params.headers || [],
        plainObject = isPlainObject(data[0]),
        keys = plainObject && (params.order || keysIndex(data)),
        oData,
        i;

    // Defaults
    var escape = params.escape || '"',
        delimiter = params.delimiter || ',';

    // Dealing with headers polymorphism
    if (!header.length)
      if (plainObject && params.headers !== false)
        header = keys;

    // Should we append headers
    oData = (header.length ? [header] : []).concat(
      plainObject ?
        data.map(function(e) { return objectToArray(e, keys); }) :
        data
    );

    // Converting to string
    return oData.map(function(row) {
      return row.map(function(item) {

        // Wrapping escaping characters
        var i = ('' + (typeof item === 'undefined' ? '' : item)).replace(
          new RegExp(rescape(escape), 'g'),
          escape + escape
        );

        // Escaping if needed
        return ~i.indexOf(delimiter) || ~i.indexOf(escape) || ~i.indexOf('\n') ?
          escape + i + escape :
          i;
      }).join(delimiter);
    }).join('\n');
  }
367543
def process_header(self, headers):
        """"""

        return [c.name for c in self.source.dest_table.columns][1:]
292774
function csvToMapping(csvString) {
  const lines = csvString.split(/\n|\r|\r\n/);
  const header = lines.shift().split(',');
  const key = header.shift();
  const now = new Date();
  const headerIdx = [];
  const fields = [];
  header.forEach((h, i) => {
    if (h === '') return;
    headerIdx.push(i);
    fields.push({key: h, format: 'text'});
  });
  const mapping = {
    created: now.toString(),
    fields: fields,
    key: key,
    mapping: {}
  };
  lines.forEach(line => {
    const values = line.split(',');
    const k = values.shift();
    mapping.mapping[k] = Array(headerIdx.length);
    headerIdx.forEach(i => {
      mapping.mapping[k][i] = values[i];
    });
  });
  return mapping;
}
1160778
public void addHeaderField(final String name, final String value)
    {
        writer.append(name + ": " + value).append(LINE_FEED);
        writer.flush();
    }
1228427
def csv_header_and_defaults(features, schema, stats, keep_target):
  """"""

  target_name = get_target_name(features)
  if keep_target and not target_name:
    raise ValueError('Cannot find target transform')

  csv_header = []
  record_defaults = []
  for col in schema:
    if not keep_target and col['name'] == target_name:
      continue

    # Note that numerical key columns do not have a stats entry, hence the use
    # of get(col['name'], {})
    csv_header.append(col['name'])
    if col['type'].lower() == INTEGER_SCHEMA:
      dtype = tf.int64
      default = int(stats['column_stats'].get(col['name'], {}).get('mean', 0))
    elif col['type'].lower() == FLOAT_SCHEMA:
      dtype = tf.float32
      default = float(stats['column_stats'].get(col['name'], {}).get('mean', 0.0))
    else:
      dtype = tf.string
      default = ''

    record_defaults.append(tf.constant([default], dtype=dtype))

  return csv_header, record_defaults
273959
public function getAllHeaderLines()
    {
        $headers = [];
        foreach ($this->getAllHeaders() as $field => $valueArray) {
            foreach ($valueArray as $value) {
                $headers[] = "{$field}: $value";
            }
        }

        return $headers;
    }
179439
def make_header(field_names, permit_not=False):
    """"""
    slug_chars = SLUG_CHARS if not permit_not else SLUG_CHARS + "^"

    header = [
        slug(field_name, permitted_chars=slug_chars) for field_name in field_names
    ]
    result = []
    for index, field_name in enumerate(header):
        if not field_name:
            field_name = "field_{}".format(index)
        elif field_name[0].isdigit():
            field_name = "field_{}".format(field_name)

        if field_name in result:
            field_name = make_unique_name(
                name=field_name, existing_names=result, start=2
            )
        result.append(field_name)

    return result
776017
def _header_line(self, section):
        """"""

        token = self.tok.get()
        what = token.value
        if what == 'id':
            self.message.id = self.tok.get_int()
        elif what == 'flags':
            while True:
                token = self.tok.get()
                if not token.is_identifier():
                    self.tok.unget(token)
                    break
                self.message.flags = self.message.flags | \
                                     dns.flags.from_text(token.value)
            if dns.opcode.is_update(self.message.flags):
                self.updating = True
        elif what == 'edns':
            self.message.edns = self.tok.get_int()
            self.message.ednsflags = self.message.ednsflags | \
                                     (self.message.edns << 16)
        elif what == 'eflags':
            if self.message.edns < 0:
                self.message.edns = 0
            while True:
                token = self.tok.get()
                if not token.is_identifier():
                    self.tok.unget(token)
                    break
                self.message.ednsflags = self.message.ednsflags | \
                              dns.flags.edns_from_text(token.value)
        elif what == 'payload':
            self.message.payload = self.tok.get_int()
            if self.message.edns < 0:
                self.message.edns = 0
        elif what == 'opcode':
            text = self.tok.get_string()
            self.message.flags = self.message.flags | \
                      dns.opcode.to_flags(dns.opcode.from_text(text))
        elif what == 'rcode':
            text = self.tok.get_string()
            self.message.set_rcode(dns.rcode.from_text(text))
        else:
            raise UnknownHeaderField
        self.tok.get_eol()
379262
def process_line(self, record):
        ""
        cleaned = []

        for key in self.vcf_fields:
            out = self.process_column(key, getattr(record, key))
            if isinstance(out, (list, tuple)):
                cleaned.extend(out)
            else:
                cleaned.append(out)

        for key in self.info_fields:
            out = self.process_column(key, record.INFO.get(key, None))
            if isinstance(out, (list, tuple)):
                cleaned.extend(out)
            else:
                cleaned.append(out)

        return cleaned