Looking to see if anyone can figure out how to read a CSV file and post only certain columns from the file.
Since WU almanac is now dead, and I have no faith in them producing a free replacement, I decided to make my own Excel spreadsheet compiling data from the NWS site for normal rain, normal temps, record hi/low.
What I would need done is first get today's month and day, then match it to a row in the CSV for today's date. Then have it display the results of column's F through M.
I've done some research, but it's out of my league for PHP. I can tweak some existing PHP, but this is too far for me.
I have my CSV file in my /csv/bwnet.csv file. I'll attach it for anyone to look at. Had to rename it to TXT file to attach. But it should be renamed to CSV.
Personally, I like to see what normal rain is for the full month. That way I can compare it to what my station is actually reporting. But for YTD rain, I like to see that added for each day, so I can compare that to annual rain fall reported so far by my station.
Temps are fairly straightforward. Like to see norms and records.
Then you would need to use a couple of 'for()' loop to extract the data, first for each month, then the data for each day of the month.
Thanks for bringing this issue up. Your comment and the resulting code snips are going to be helpful for something I need to do when a few other things get done.
I respect this forum and the sharing by so many intelligent folks here.
return array_slice($row, 5, 8); //Rows "F" through "M"
Where would I input the filename? bwnet.csv?
Looking at my file, I actually want to use the 3rd column, then 7 through 13 or end. Would it be easier to shuffle those columns around in Excel so they are in a row?
Then another section named Normal Highs/Lows instead of Normal Rain. With a line below looking the same as Normal Rain with those records. This would use the last two column values.
Then another section named Record Highs/Lows instead of Normal Rain. With a line below looking the same as Normal Rain with those records. Then this one would use the 8-11 values. So in the end, there will be 3 total sections.
, , etc? I guess I don't want the brackets printed on screen. Just the values within.
Thanks for the help. Getting the data out worked out easier than I had expected. It's mainly a matter of getting it formatted now.
We are in our HTML now.
All those indexes like 'NormLow' come from the top row of the CSV. So technically this routine will work on ANY csv as long as the top row contains column names, the first column is the month number, and the second column is the day of the month number.
OK, thanks. I'll look into it more later in the week when I have more time.