ktlacaelel / php-csv-parser

Automatically exported from code.google.com/p/php-csv-parser
0 stars 0 forks source link

Not respecting EOL (end of line) settings #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
--What steps will reproduce the problem?--

1. Upload a CSV file that doesn't have ; as an eol - e.g. try one that has \r\n 
as a line ending.

--What is the expected output? What do you see instead?--

Expected to be able to specify 'eol' via the settings and for it to parse 
correctly.

--What version of the product are you using? On what operating system?--

1.0.0 stable on a CentOS 5 server running PHP 5.2.7

--Please provide any additional information below.--

I looked through the code and noted that although 'eol' can be specified in the 
settings, it isn't 
actually used anywhere.  I fixed it by adding:

ini_set('auto_detect_line_endings',TRUE);

on line 2146 before the call to fopen() and fgetcsv() in the parse() function.  
Hope that helps 
somebody or can be added to a future version.

Original issue reported on code.google.com by bendodso...@gmail.com on 25 Jun 2009 at 11:55

GoogleCodeExporter commented 9 years ago
Hi ben, thank you for posting this issue.
I am guessing that you can understand why I cannot add that to the library.

because if someone has specified 

ini_set('auto_detect_line_endings', false);

and this library changes things well then it'll brake their code.
this is something that should definitely be in the documentation.

Thank you, for taking the time to post this here, and apologies for my late 
reply.
the truth is that I've been really busy on other stuff and haven't taken a look 
at
this project for a while now.

Your point is valid, but it might be a little too much by silently overriding it
inside of the library.

may be I should read the previous value force it to be true and then restore the
original value!?

let me think about it, and also will talk with the guys at the pear community 
they
may have some ideas.

- Kazuyoshi Tlacaelel.

Original comment by kazu....@gmail.com on 7 Nov 2009 at 11:36

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for your reply :)

I don't think you need to use the ini_set at all - that was just a workaround 
for me as it was the easiest way 
with my setup.  However, you are specifying an "eol" option in the settings it 
just doesn't get used.  If you can 
make your script use whatever is in the "eol" settings (defaulting to ";") then 
someone like me could just add 
"\r\n" as a parameter and it should work?  I don't think you need to 
auto-detect what people are using as 
they should specify it at runtime.

Thanks,

Ben

Original comment by bendodso...@gmail.com on 7 Nov 2009 at 3:26

GoogleCodeExporter commented 9 years ago
I think you sould be able to specify it by passing an array of parsing options!

{{{

    /**
     * csv parsing default-settings
     *
     * @var array
     * @access public
     */
    $settings = array(
        'delimiter' => ',',
        'eol' => ";",
        'length' => 999999,
        'escape' => '"'
    );

}}}

Original comment by kazu....@gmail.com on 25 Feb 2010 at 9:06

GoogleCodeExporter commented 9 years ago
As I mentioned above, whilst "eol" is in the settings config, that setting is 
not actually used anywhere within the 
class so setting it or changing it makes no difference.

Ben

Original comment by bendodso...@gmail.com on 25 Feb 2010 at 9:32