I use PHP to display car GPS device data from a CSV file. This data is captured at least every 30 seconds for more than 70 vehicles and includes 19 data columns. This creates several thousand rows of data and files about 614 KB in size. New data is added to the end of the file. I need to pull out the last row of data for each car, which should be the most recent status. I can pull one line for each block, however, since the CSV file is in chronological order, I pull out the oldest data in the file, not the latest. Is it possible to read CSV from end to start? I saw some solutions, however, they usually include loading the entire file into memory and then reversing it, it sounds very inefficient. Do I have any other options? Thank you for any advice.which you can offer.
EDIT . I use this data to display real-time locations on the fly. The data is provided only to me in CSV format, so I think that import into the database is out of the question.
source
share