Are you sure this is right? It doesn't smell right to me.

  public function setDelimiter($delimiter) {
    $this->delimiter = ',';
  }

A setter should set the value it's given to the field it's supposed to set. That's not what this does.

Also, if you create a feed and specify a delimiter other than comma in the form, it doesn't behave as if it was told the delimiter you set. Instead it behaves as if ',' is the delimiter.

Comments

reikiman’s picture

Oh, uh, that function is in parser_csv_parser.inc (in case it's not obvious)

reikiman’s picture

I changed that function to the expected, and it behaved properly based on the delimiter setting.

public function setDelimiter($delimiter) {
    $this->delimiter = $delimiter;
  }

What I'm meaning is I have a file whose delimiter is '|'. Specifying that file it came up with a confused idea of the fields. Modifying parser_csv_parser.inc to hardcode the delimiter to '|' from the hardcoded ',' as it is now, and it came up with the correct idea of the fields, and properly created nodes with the correct fields. Making the above change also results with correctly created nodes with the correct fields.

jpetso’s picture

Status: Active » Reviewed & tested by the community

Yah, sorry, that was my fault. I thought it was a porting error when transforming the original parser_csv_parser.inc into the version on Launchpad (http://launchpad.net/php-csv) - I already fixed it there, but hadn't suspected that it's in this module's version of the parser as well.

The suggested fix is the right one, please commit reikiman's changes from comment #2 or update to the Launchpad version altogether. Thanks!