Reputation: 4498
I have a somewhat irregularly structured CSV file I'm reading with fopen()
and fgetcsv()
. The first 5 lines are to be discarded.
Is there an efficient way to discard those 5 lines? What I have now is:
$fp = fopen($path,'r');
fgets($fp);fgets($fp);fgets($fp);fgets($fp);fgets($fp);
which gets the job done, but seems dirty.
Upvotes: 0
Views: 156
Reputation: 21661
So like this
$CSV = new SplFileObject($file);
$CSV->seek(5);
$row = $CSV->fgetcsv();
Upvotes: 6