I have a csv file containing wave data (time, tidal elevation, wave period, wave height and wave direction) I want to know, at a given time, when the previous high tide was and the corresponding wave period, height and direction.
I have this code now which selects the line of the time that I'm looking for:
import csv
with open ('Waves_2019.csv') as f:
reader = csv.reader (f)
for line_num, content in enumerate(reader):
if content [0] == '01/03/2019T08:00':
a = line_num
print (a)
The next step would then take the previous 12 hours of data to select the highest tidal elevation (0.77 at 01/03/2019T01:00 in example) and then return the other data (period, height, direction).
How could I amend the code that it looks for the max tidal elevation in column 2 based on the previous 12 data points of the selected time? And then return the other data during that high tide?