read second line or record of csv file

Reply

Join Date: May 2007
Posts: 5
Reputation: redcoder07 is an unknown quantity at this point 
Solved Threads: 0
redcoder07 redcoder07 is offline Offline
Newbie Poster

read second line or record of csv file

 
0
  #1
Jul 23rd, 2007
Anyone know how to read the second line from a csv file using PHP? I need the read the second line from the csv file and import into mysql
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,355
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 500
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: read second line or record of csv file

 
0
  #2
Jul 23rd, 2007
Here's a tutorial that should get you there:
http://www.goodphptutorials.com/track/62
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 5
Reputation: redcoder07 is an unknown quantity at this point 
Solved Threads: 0
redcoder07 redcoder07 is offline Offline
Newbie Poster

Re: read second line or record of csv file

 
0
  #3
Jul 23rd, 2007
Is there mentioned how to read second row onwards or any particular row onwards from csv file? I try look at that wrbsite but couldn't find it.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,355
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 500
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: read second line or record of csv file

 
0
  #4
Jul 23rd, 2007
Originally Posted by redcoder07 View Post
Is there mentioned how to read second row onwards or any particular row onwards from csv file? I try look at that wrbsite but couldn't find it.
Right in the middle of the table of contents there is a link to the section "Working with CSV".
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 5
Reputation: redcoder07 is an unknown quantity at this point 
Solved Threads: 0
redcoder07 redcoder07 is offline Offline
Newbie Poster

Re: read second line or record of csv file

 
0
  #5
Jul 23rd, 2007
Yeah, thats the one i searched for, but couldn't get the answer
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,355
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 500
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: read second line or record of csv file

 
0
  #6
Jul 23rd, 2007
This code opens and reads a line into $line until there are no more lines:
  1. <?php
  2. $fp = fopen('file.csv', 'r');
  3. while (!feof($fp)) {
  4. $line = fgetcsv($fp, 4096);
  5. echo $line; // do whatever you need here
  6. }
  7. fclose($fp);
  8. ?>

file_get() can be used as well, to load each line into an array, if you prefer to work with it like that.
Last edited by Ezzaral; Jul 23rd, 2007 at 2:08 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 5
Reputation: redcoder07 is an unknown quantity at this point 
Solved Threads: 0
redcoder07 redcoder07 is offline Offline
Newbie Poster

Re: read second line or record of csv file

 
0
  #7
Jul 24th, 2007
Alright, i got you now. meaning i can do some skipping code to replace
echo $line; // do whatever you need here

with some code that read the string is not equal to the column name in the csv file and proceed to insert.

Thanks for your help. Really appreciated
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: premmaneesh is an unknown quantity at this point 
Solved Threads: 0
premmaneesh premmaneesh is offline Offline
Newbie Poster

Re: read second line or record of csv file

 
0
  #8
May 4th, 2009
i am also confused how to get a specific row from a csv file, is anyone know how to do it ?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,355
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 500
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: read second line or record of csv file

 
0
  #9
May 4th, 2009
Did you read any of the posts above? Did you understand them? If not, what didn't you understand? You need to learn how to ask questions.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC