Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
nicholas maddren
12,793 PointsFOpen & CSV Files
Hello community :) I have a client wanting their data displayed on the front end of their website. The data is stored in a CSV file that is uploaded onto their server daily. Would it be good practice to display this data straight from the CSV file using FOpen? The data in the CSV file contains vehicles for sale and need to dissolve if they no longer appear in the CSV file. Before I start developing I would like to know the best method for this. I will be using wordpress and would like to show a history in the backend of all cars sold. I am starting to think that I would need to use more than FOpen if I am wanting to store a history of vehicles. Any help on this would be great thanks :)
1 Answer
Ron McCranie
7,837 PointsYou could open the CSV file every time the data is requested but that would be highly inefficient. I think a better method, which might be a little more advanced, would be to setup a cron job to run after the file is uploaded (maybe an hour later). That cron job would just run a PHP file, which could add all new CSV rows to a database and update rows if some other data for an existing vehicle has changed. This way you have a database to work with instead of opening a CSV file every time someone requests the data. This will be faster and give you more flexibility in analyzing and displaying the data.