Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Bug #2827 File_CSV::discoverFormat() is unable to discover format in one column CSV file
Submitted: 2004-11-25 11:27 UTC
From: jocke at selincite dot com Assigned: dufuz
Status: Closed Package: File
PHP Version: 4.3.8 OS: Linux
Roadmaps: 1.3.0a1    
Subscription  


 [2004-11-25 11:27 UTC] jocke at selincite dot com
Description: ------------ We're using File_CSV to parse and store imported CSV data. This works fine except for when the CSV file only contains one column, such as === a@b.com c@d.net e@f.org === When using File_CSV::discoverFormat(), the following warning is issued: === Warning: Could not discover the separator in /var/www/html/PEAR/PEAR.php on line 762 === The reason for this is obviously that the file doesn't contain any separator character, however the file is still a completely valid CSV file (AFAIK). Thanks! Reproduce code: --------------- Save === a@b.com c@d.net e@f.org === to a file, say /tmp/onecol.csv and run the following code: === $aConfig = File_CSV::discoverFormat("/tmp/onecol.csv"); === Expected result: ---------------- $aConfig to be Array ( [fields] => 1, [sep] => NULL, [quote] => NULL ) Or some other format that aids the next method used (typically: File_CSV::read()) Actual result: -------------- Pear warning: Warning: Could not discover the separator in /var/www/html/PEAR/PEAR.php on line 762

Comments

 [2004-11-29 11:40 UTC] jocke at selincite dot com
Hi, I've 'fixed' the problem by commenting the if-statement that generates the error message. This seems to work fine on our system, but I'm sure that someone can fix a much more elegant solution to this problem. I'm pasting the diff here; it might help someone resolve the problem temporarily, and hopefully a developer might be able to use it as a starting-point for a better solution. Cheers, /JS Patch for CSV.php === 385,388c385,387 < // This if-statement generates error when reading a one-column CSV file < // if (empty($fields)) { < // return File_CSV::raiseError('Could not discover the separator'); < // } --- > if (empty($fields)) { > return File_CSV::raiseError('Could not discover the separator'); > } ===
 [2004-12-05 20:20 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2004-12-22 16:10 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!