Skip to content

Instantly share code, notes, and snippets.

@Kalli
Last active December 16, 2015 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kalli/5450761 to your computer and use it in GitHub Desktop.
Save Kalli/5450761 to your computer and use it in GitHub Desktop.
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