Skip to content

Import file without enclosure character #35

Open

Description

@BillyTom

I would like to import a text-file that uses only delimiter characters and no enclosure characters, like: value1;value2;value3 etc.

If I try to set the enclosure character to an emtpy string, false or null I get the following error:

"Warning: SplFileObject::setCsvControl(): enclosure must be a character in project/vendor/goodby/csv/src/Goodby/CSV/Impor\/Standard\/Lexer.php line 51 

In order to make it work I've changed the the SplFileObject that is beeing used in the Lexer.php, namely $csv->setCsvControl($delimiter, $enclosure, $escape);

The PHP-documentation SplFileObject::setCsvControl lists three optional parameters: $delimiter, $enclosure and $escape www.php.net/manual/en/splfileobject.setcsvcontrol.php

The only way I have managed to parse a file without enclosures was to change $csv->setCsvControl($delimiter, $enclosure, $escape); to $csv->setCsvControl($delimiter);. This worked for me since I did not use the escape character anyway, but I was wondering if there was a better way to accomplish this.

Activity

  1. LunarDevelopment commented on Oct 7, 2015

    @LunarDevelopment

    👍

  2. gooddaytoday commented on May 5, 2016

    @gooddaytoday

    PHP 5.3, I have similar error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions