scott.stephan Posted July 7, 2009 Share Posted July 7, 2009 I've never had this problem. I'm sure this is a 100% stupid question, but I'm swamped with about 400 tiny projects and I don't quite have time to do my due diligence on this one. Anyhow- I'm having a problem where when I use fputcsv to create a CSV from my array, it's not reading line breaks and I'm getting a file with one row that's about 10,000 columns/fields long! I've never had this problem with fputcsv before and I'm a little befuddled. Code below: <?php $handle = fopen("RetailerSpreadsheet.csv", "r"); $row=0; //# of rows $count=0; //# of fields $row_complete=""; //String of complete row $list=array(); //Holds complete rows for output to usable CSV $c=0; //Array counter $title=""; //Display title of loc $address=""; //Display address + address for lat/lon calc $phone=""; //Phone # is applicable while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $title=$data[2]; $address=$data[3].",".$data[4].",".$data[5].",".$data[6].",".$data[7].",".$data[8].",".$data[9]; //Going to need a special enclosure to avoid problems with "," $phone=$data[10]; $row_complete= $title.",".$address.",".$phone ; $list[$c]=$row_complete; $c++; echo "FINAL ROW: $row_complete <br/>"; } $filename="UpdatedRetailerSheetforStoreLoc.csv"; $fp = fopen($filename, 'w'); fputcsv($fp,$list); fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/165073-line-ending-problem-with-fputcsv/ Share on other sites More sharing options...
Mark Baker Posted July 7, 2009 Share Posted July 7, 2009 Why are you using fputcsv when you're doing all the comma-separation coding yourself. Doesn't duplication of effort not only waste all the effort, but also cause all your problems? Link to comment https://forums.phpfreaks.com/topic/165073-line-ending-problem-with-fputcsv/#findComment-870459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.