php - Returning selected rows from a csv -
i'm using php(fgetcsv) in order parse csv file. file continuously updated , quite large. possible return selected number of rows(say first 10 rows example)?
i think can read data row wise , return whichever rows want keeping track @ current row number.
$pickedrows = array(1, 3, 5); $currentrow=0; $thedata = array(); if (($handle = fopen("test.csv", "r")) !== false) { while (($data = fgetcsv($handle, 1000, ",")) !== false) { if(in_array(currentrow, $pickedrows)) $thedata[] = $row; $currentrow++; } fclose($handle); }
Comments
Post a Comment