You are here

protected function FeedsCSVParser::parseHeader in Feeds 7

Same name and namespace in other branches
  1. 6 plugins/FeedsCSVParser.inc \FeedsCSVParser::parseHeader()
  2. 7.2 plugins/FeedsCSVParser.inc \FeedsCSVParser::parseHeader()

Get first line and use it for column names, convert them to lower case. Be aware that the $parser and iterator objects can be modified in this function since they are passed in by reference

Parameters

ParserCSV $parser:

ParserCSVIterator $iterator:

Return value

An array of lower-cased column names to use as keys for the parsed items.

1 call to FeedsCSVParser::parseHeader()
FeedsCSVParser::parse in plugins/FeedsCSVParser.inc
Implements FeedsParser::parse().

File

plugins/FeedsCSVParser.inc, line 41

Class

FeedsCSVParser
Parses a given file as a CSV file.

Code

protected function parseHeader(ParserCSV $parser, ParserCSVIterator $iterator) {
  $parser
    ->setLineLimit(1);
  $rows = $parser
    ->parse($iterator);
  if (!count($rows)) {
    return FALSE;
  }
  $header = array_shift($rows);
  foreach ($header as $i => $title) {
    $header[$i] = trim(drupal_strtolower($title));
  }
  return $header;
}