Creating timetable from excel for rainfall data

1 次查看(过去 30 天)
Hello,
I am trying to import the excel data on hourly rainfall (attached) to calculate the daily, monthly, and annual rainfall.
Could anybody help me with creating timetable for the above dataset so that it would be possible to apply retime approach to calculate the daily/monthly?
Many thanks.

采纳的回答

Guillaume
Guillaume 2019-5-19
Considering that excel has a perfectly working date/time time, one must wonder why you're not using it. At least, encoding the date and time as characters would make more sense than this completely non-standard date and time storage. In particular using hour 24 on the current day instead of hour 0 on the next day makes no sense at all.
badlyformatteddata = readtable('RAINFALL_HOURLY.xlsx');
rainfall = table2timetable(badlyformatteddata(:, 'RainMm'), 'RowTimes', datetime(compose('%d %06d', badlyformatteddata.Date, mod(badlyformatteddata.Time, 240000)), 'InputFormat', 'yyyyMMdd HHmmss'));
rainfall.Time(hour(rainfall.Time) == 0) = rainfall.Time(hour(rainfall.Time) == 0) + days(1) %To account for that stupid hour 24
  5 个评论
Guillaume
Guillaume 2019-5-20
编辑:Guillaume 2019-5-20
Ah, ok, in that case, I would set the time to the beginning of the sampling instead of the end by subtracting 1 hour from all the times. This actually makes the decoding slightly simpler (and saner):
badlyformatteddata = readtable('RAINFALL_HOURLY.xlsx');
rainfall = table2timetable(badlyformatteddata(:, 'RainMm'), 'RowTimes', datetime(compose('%d %06d', badlyformatteddata.Date, badlyformatteddata.Time-10000), 'InputFormat', 'yyyyMMdd HHmmss'))

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by