Creating timetable from excel for rainfall data

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Guillaume
Guillaume il 19 Mag 2019
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 Commenti
Guillaume
Guillaume il 20 Mag 2019
Modificato: Guillaume il 20 Mag 2019
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'))

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by