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

Bug #5553 File_CVS should detect an occurance of delimeter in field and escape
Submitted: 2005-09-29 04:40 UTC
From: doconnor Assigned: dufuz
Status: Closed Package: File
PHP Version: Irrelevant OS:
Roadmaps: 1.3.0a1    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 48 + 40 = ?

 
 [2005-09-29 04:40 UTC] doconnor
Description: ------------ If you select a single comma as your seperator, and try to print out a value into a field that contains a comma, you gain an extra column. if $conf["sep"] is found in $data, the $data entry is escaped with quotes. Test script: --------------- $conf = array(); $data = array(); $conf["fields"] = 3; $conf["sep"] = ","; $filename = "accounts.csv"; $data[] = "Hi"; $data[] = "Hello"; $data[] = "Hi,world"; File_CSV::write($filename,$data,$conf); Expected result: ---------------- Hi,Hello,"Hi,world" Actual result: -------------- Hi,Hello,Hi,world

Comments

 [2005-09-30 01:23 UTC] dufuz
IMHO it is a bug rather then request ;-) I'll try to look into this when I have enough time from work.
 [2007-03-20 20:46 UTC] dufuz (Helgi Þormar)
I've made a fix so that the quotes are only ever added if the string contains a separator, the previous way as a bit silly and added quotes around every single string, even when they didn't require it but what you lacked in your code is: $conf['quote'] = '"'; or what ever sep you'd like, File_CSV defaults to null if no quotes are defined so basically things wouldn't work anyway for you unless you passed that :) I'll close this bug when I commit the fixup
 [2007-03-22 17:09 UTC] dufuz (Helgi Þormar)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.