? 776854-21_no_headers.csv ? 776854-21_no_headers_D6.patch ? feeds_noheaders_1.patch ? libraries/simplepie.inc Index: plugins/FeedsCSVParser.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsCSVParser.inc,v retrieving revision 1.16.2.1 diff -u -p -r1.16.2.1 FeedsCSVParser.inc --- plugins/FeedsCSVParser.inc 25 Oct 2010 22:43:03 -0000 1.16.2.1 +++ plugins/FeedsCSVParser.inc 28 Oct 2010 20:36:15 -0000 @@ -19,11 +19,14 @@ class FeedsCSVParser extends FeedsParser $delimiter = $source_config['delimiter'] == 'TAB' ? "\t" : $source_config['delimiter']; $parser->setDelimiter($delimiter); - $header = $this->parseHeader($parser, $iterator); - if (!header) { - return; + if ($source_config['no_headers'] < 1) { + // Get first line and use it for column names, convert them to lower case. + $header = $this->parseHeader($parser, $iterator); + if (!header) { + return; + } + $parser->setColumnNames($header); } - $parser->setColumnNames($header); // Populate batch. $batch->items = $this->parseItems($parser, $iterator); @@ -88,6 +91,7 @@ class FeedsCSVParser extends FeedsParser public function sourceDefaults() { return array( 'delimiter' => $this->config['delimiter'], + 'no_headers' => $this->config['no_headers'], ); } @@ -126,6 +130,12 @@ class FeedsCSVParser extends FeedsParser ), '#default_value' => isset($source_config['delimiter']) ? $source_config['delimiter'] : ',', ); + $form['no_headers'] = array( + '#type' => 'checkbox', + '#title' => t('No Headers'), + '#description' => t('Check if the imported CSV file does not start with a header row. If checked, mapping sources must be named \'0\', \'1\', \'2\' etc.'), + '#default_value' => isset($source_config['no_headers']) ? $source_config['no_headers'] : 0, + ); return $form; } @@ -133,7 +143,10 @@ class FeedsCSVParser extends FeedsParser * Define default configuration. */ public function configDefaults() { - return array('delimiter' => ','); + return array( + 'delimiter' => ',', + 'no_headers' => 0, + ); } /** @@ -152,6 +165,12 @@ class FeedsCSVParser extends FeedsParser ), '#default_value' => $this->config['delimiter'], ); + $form['no_headers'] = array( + '#type' => 'checkbox', + '#title' => t('No headers'), + '#description' => t('Check if the imported CSV file does not start with a header row. If checked, mapping sources must be named \'0\', \'1\', \'2\' etc.'), + '#default_value' => $this->config['no_headers'], + ); return $form; } }