retrieving top ten records from csv file using asp/php/asp.net
I am using Asp scripting lang, I want to disaply top ten r开发者_如何学JAVAecords from a csv file. How is it possible?
While looping through the CSV file, you could create a variable and increment it with each iteration and once it reaches 10, you exit out of the loop:
PHP Example
$counter = 0;
foreach($csv as $line)
{
$counter++;
// your code........
if ($counter === 10) break;
}
ASP Example
Dim Counter
Counter = 0
For Each line In csv
Counter = Counter + 1
' your code
If Counter = 10 Exit For
Next
精彩评论