Reading Most Recent CSV File in Directory


Posted on 16th Feb 2014 07:03 pm by admin

I thought I had wrapped this project up, but found out that the program I use to FTP a csv file to my website is best used in time stamp mode.

That is, each day a newly named csv file is uploaded with that days data.

Did you know?Explore Trending and Topic pages for more stories like this.
I currently have this script that I use to display the data on my website:

PHP Code:

echo "<table align='left' width='685' bordercolor='ccc' border='1'>";
echo "<tr><td><strong>Date</strong></td><td><strong>MPSAS</strong></td><td><strong>NELM</strong></td><td><strong>Temp (C)</strong></td></td>";
$file = "myfile.csv";
$content=file("$file");
for ($i = count($content) - 1; $i >=1 ; $i--) {
$row = explode(",", $content[$i]);
echo "<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[7]}</td></td>";}echo "</table>";
?>


To read the most recent file I know I need to list the dir contents, sort, and then select the newest file, but I need some help getting started.

Anyone have experience with that is willing to help me out?
No comments posted yet

Your Answer:

Login to answer
164 Like 26 Dislike
Previous forums Next forums
Other forums

Multi Dimensional Array Append
Hi Guys

I have a function that returns a multidimentional array eg

$result = functio

need help in update query
hi
i have a dynamic form. i need help in how can i use update query when values from dynamic for

Legal Issues for SAP ERP o ERP in general
Hi experts,

Can someone please help me finding some documentation about legal issues tha

Can't shake the "Warning: include()" error
I've just uploaded my site to a new server and where I have PHP include tags in my HTML, the browser

Guixt issue
Hello all,

We are experiencing the following problem with Guixt:

Some transact

PHP code needed to get/post form fields and request mysql query results.
I'm new to PHP

I've created an html form to allow the user to request a basic telephone dire

Mass activity scheduling
Hi experts,

Im facing some problems to deal with mass activity jobs.
When I run some

Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.

If i send the value by this

Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.

What I'm doin

mysq_num_rows
Hi,

I want to use:

Code: if(mysql_num_rows($ergebnis2)==2)
how can the value 2, be

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash