acctman Posted December 10, 2010 Share Posted December 10, 2010 I need help rewriting the $row_count... the problem is that its not working when the first row does not have quotations. its a strange problem, no errors it just does not process. Once I comment out the row_count the $data is outputted as normal. And when I process a file that has quotations it works. So i just need a better way of saying skip the first row in the $data output since thats the header. $uploadcsv = "/files/004AM.csv"; $handle = fopen($uploadcsv, 'r'); $column_headers = array(); $row_count = 0; while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { if ($row_count==0){ $column_headers = $data; } else { print_r($data); } ++$row_count; } Link to comment https://forums.phpfreaks.com/topic/221242-omitting-row-from-csv/ Share on other sites More sharing options...
litebearer Posted December 10, 2010 Share Posted December 10, 2010 just an old man's ramblings... $file_name = "/files/004AM.csv"; $lines = file($file_name); if(count($lines)>1){ while($i=1; $i<=count($lines); $i ++) { echo $lines[$i] . "<br>"; } } Link to comment https://forums.phpfreaks.com/topic/221242-omitting-row-from-csv/#findComment-1145490 Share on other sites More sharing options...
acctman Posted December 10, 2010 Author Share Posted December 10, 2010 just an old man's ramblings... $file_name = "/files/004AM.csv"; $lines = file($file_name); if(count($lines)>1){ while($i=1; $i<=count($lines); $i ++) { echo $lines[$i] . "<br>"; } } thanks, how would I apply this to work with the fgetcsv coding that I'm currently using. Link to comment https://forums.phpfreaks.com/topic/221242-omitting-row-from-csv/#findComment-1145509 Share on other sites More sharing options...
acctman Posted December 11, 2010 Author Share Posted December 11, 2010 any idea? Link to comment https://forums.phpfreaks.com/topic/221242-omitting-row-from-csv/#findComment-1145617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.