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.

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?

164 Like 26 Dislike
Previous php-forum Next php-forum
Other php-forum

Small problem with image resize script
Hi!

I am a little bit new to php and I have an issue installing an image resize script I down

phph within href not showing php if change ? to &
Code: [Select]<a href="<?php echo $puser; ?>?m=<?php=(($m-1)&l

Best way to cross matching large datasets
Hi,

Im running a script where am I cross matching about 200 000 data sets with each other. Ea

MYSQL gen help
This is my Mysql gen. can anyone tell me why this echos

MID(networkset.networkid, 3, 3) AS &q

How to show more than 1 users with this code...
Hello,
i have a table that shows users only if I, as Administrator, want to be shown. But its sho

Can I call a class inside a function?
I have a class written in another file that handles my image resizing.

Can I do this (php say

Multi Level Array Problem
hi all,

For example I have array like below:

$temp = array(array('north america', 'us'

Executing an exe
Hi. I have some bizarre problem with exec (other any other method) to launch exe's. I am making a ga

cURL proxy
Okay here is the thing... i know how to add proxys

Code: curl_setopt($ch, CURLOPT_PROXYTYPE,

insert/update functions for mysql, what do you think?
I am working on two really simple functions that automatically generate (and execute) insert and upd

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