Last active
December 16, 2015 14:40
-
-
Save Kalli/5450761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import time | |
sample=csv.reader(open("/vedurmaelingar-a-islandi.csv","r")) | |
# gögnin eru á forminu: | |
# ["YYYY-mm-dd H:M:S", hámarkshitastig, lágmarkshitastig, úrkoma] dæmi: | |
# ["2002-04-25 18:00:00", "3.9", "1.8", "0.5"] | |
frost=[] | |
notfrost=[] | |
for row in sample: | |
aday=time.strptime(row[0],"%Y-%m-%d %H:%M:%S") | |
if aday.tm_mon==4 and aday.tm_wday==3 and aday.tm_mday in range(19,26): | |
# fimmtudagur í apríl frá 19. til 26. | |
try: | |
if float(row[2])<0: | |
if int(aday.tmyear) not in frost: | |
frost.append(int(aday.tm_year)) | |
else: | |
if int(aday.tmyear) not in notfrost: | |
notfrost.append(int(aday.tm_year)) | |
except: | |
print("exception: "+row) | |
# hiti er mældur oft á dag, ár geta hafað lent í notfrost ef ein mæling yfir daginn sýndi hita yfir frostmarki | |
# filterum því út: | |
print("Ár sem frusu ekki saman: ") | |
for year in notfrost: | |
if year not in frost: | |
print(year) | |
print("") | |
print("Ár sem frusu saman: ") | |
for year in frost: | |
print(year) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment