[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Not getting data when trying to use fgetcsv() twice.

Posted on 2012-03-31
4
Medium Priority
?
678 Views
Last Modified: 2012-03-31
I've opened up a csv file using:

$fp = @fopen ("myfile.csv","r");

if($fp){

$lastrow;

while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) {      
      
      //get first day of data
     $lastrow = $data;
}

//cycle through again using lastrow as input
while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) {      
      
  //use last row as input

}



I cycle through the csv file and get the last row using the above code.  I want to cycle through the csv file again using the last row as input to extract other data.

I've tried using fseek to reset the pointer to the beginning of the file but I get this error message:  Warning: fseek() [function.fseek]: stream does not support seeking in




How can I cycle through the csv file twice?
0
Comment
Question by:dmalovich
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37791866
You can use rewind() http://us2.php.net/manual/en/function.rewind.php as long as it is a local file.  If it's 'http' or 'ftp', it doesn't work.
0
 

Author Comment

by:dmalovich
ID: 37791921
It is http.  Do you have any other suggestions maybe?
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 37791927
Close and re-open is your only choice I think.
0
 

Author Closing Comment

by:dmalovich
ID: 37791973
Yah I think so too, thanks......
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question