![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
fopen() and fgetcsv()
I am using fopen() and fgetcsv() to open an excel file and extract data for
upload to mysql database. The doesnt seem to be a parameter in either of these functions for ommitting the first row of the excel file. I am currently using While ...... statement to read the rows and do things with them. Can I ommit the first line without replacing my 'While....' loop with a 'For......' loop? Ian |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: fopen() and fgetcsv()
mantrid wrote:
> I am using fopen() and fgetcsv() to open an excel file and extract data for > upload to mysql database. The doesnt seem to be a parameter in either of > these functions for ommitting the first row of the excel file. I am > currently using While ...... statement to read the rows and do things with > them. Can I ommit the first line without replacing my 'While....' loop with > a 'For......' loop? > > Ian > > Certainly, take your pick, both should work fine: $i = 0; while ($i++ && false !== $data = fgetcsv($fh, 1024)) { if ($i == 1) continue; print_r($data); } $firstline = true; while (false !== $data = fgetcsv($fh, 1024)) { if ($firstline == true) { $firstline = false; continue; } print_r($data); } - Michael |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: fopen() and fgetcsv()
mantrid wrote:
> I am using fopen() and fgetcsv() to open an excel file and extract data for > upload to mysql database. The doesnt seem to be a parameter in either of > these functions for ommitting the first row of the excel file. I am > currently using While ...... statement to read the rows and do things with > them. Can I ommit the first line without replacing my 'While....' loop with > a 'For......' loop? > > Ian > > Certainly, take your pick, both should work fine: $i = 0; while ($i++ && false !== $data = fgetcsv($fh, 1024)) { if ($i == 1) continue; print_r($data); } $firstline = true; while (false !== $data = fgetcsv($fh, 1024)) { if ($firstline == true) { $firstline = false; continue; } print_r($data); } - Michael |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |