I guess it's not so difficult but I'm really stuck. I have some files, named with a string of 9 numbers, like:
003485295.lst
005847283.lst
092348235.lst
...
Each file identifies a measurement station, and contains a table with two columns, date
and value
, separated by a space character. For example, 003485295.lst
is:
date value //header row here!
2014-01-03-07:00-00 2.2
2014-01-04-07:00-00 3.1
2014-01-05-07:00-00 28.6
2014-01-06-07:00-00 2.5
2014-01-14-07:00-00 5.6
...
Some dates are common among all files (stations), but some are not.
What I'm looking for
I have chosen one particular date, say 2014-01-06
. I want to:
- create an empty result file, say
2014-01-06.txt
; - cycle through all of my
*********.lst
files; - search if station
********
took some measurementMM.M
that day; - add a row in my result file, following the pattern stationId-value, like
******** MM.M
(could also beM.M
, orMMM.M
).
So the desired output, 2014-01-06.txt
, is something like:
003485295 2.5 //as we read in 003485295.lst
001022903 6.4
001022905 6.6
001022907 10.3
001026202 30.6
...
Stations that had no value at all for that day should be excluded. I'm on Windows and have R
and MATLAB
in my hands, but could work with other tools as well.