merijn van der leek
asked on
Finding the longest freezing period in a csv with python.
I wanna know the longest freezing period from a csv.
The format of the csv is this:
01-06 STAID: Station identifier
08-13 SOUID: Source identifier
15-22 DATE : Date YYYYMMDD
24-28 TX : Maximum temperature in 0.1 °C
30-34 Q_TX : quality code for TX (0='valid'; 1='suspect'; 9='missing')
STAID,SOUID,DATE,TX,Q_TX
162,100522,19010101,-31,0
162,100522,19010102,-13,0
162,100522,19010103,-5,0
162,100522,19010104,-10,0
162,100522,19010105,-18,0
162,100522,19010106,-78,0
Does anyone know a way to find the longest freezing period and print it in the format:
The longest freezingperiod was 12 days and ended on 29 jun 1999. (example)
Any help would be very much appreciated :)
The format of the csv is this:
01-06 STAID: Station identifier
08-13 SOUID: Source identifier
15-22 DATE : Date YYYYMMDD
24-28 TX : Maximum temperature in 0.1 °C
30-34 Q_TX : quality code for TX (0='valid'; 1='suspect'; 9='missing')
STAID,SOUID,DATE,TX,Q_TX
162,100522,19010101,-31,0
162,100522,19010102,-13,0
162,100522,19010103,-5,0
162,100522,19010104,-10,0
162,100522,19010105,-18,0
162,100522,19010106,-78,0
Does anyone know a way to find the longest freezing period and print it in the format:
The longest freezingperiod was 12 days and ended on 29 jun 1999. (example)
Any help would be very much appreciated :)
@Martyn
See this related question:
https://www.experts-exchange.com/questions/29160662/Finding-the-minimum-and-maximum-of-a-csv.html
See this related question:
https://www.experts-exchange.com/questions/29160662/Finding-the-minimum-and-maximum-of-a-csv.html
ASKER
He it is a homework question which i am having a hard time with so if u got any ideas coding wise i would love to hear them!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Given that you say it is a homework question, it would be better for you to ask questions and learn, rather than have us do the work for you. The question linked by aikimark should set you on your way.
That being said, this is the kind of thing a database does really well. I am sure that a spreadsheet could also be used, but it depends on how often you will be doing this.
If it were something that you were going to be doing regularly, perhaps consider importing the data into a database and writing some code to handle the calculation. Alternatively, it would also be possible to create a simple program that would provide the information for you. I note that you tagged this with Python, so perhaps you are asking someone to code a solution for you? What have you tried? This looks rather like a homework question otherwise.