Skip to content

Instantly share code, notes, and snippets.

@webbyfox
Last active August 29, 2015 13:56
Show Gist options
  • Save webbyfox/9102480 to your computer and use it in GitHub Desktop.
Save webbyfox/9102480 to your computer and use it in GitHub Desktop.
import csv
import calendar
from datetime import datetime
current = datetime.now()
filename = str(current.strftime('%m%Y')) + str('.csv')
def getDictOutput(args):
name_dict = ['Date','Fajr_Begins','Fajr_Jammt','Sunrise','Zuhr Begins','Zuhr_Jamaat', \
'Asr_Begins','Asr_Jamaat','Magrib', 'Esha_Begins', 'Esha_Jammat']
time_dict = []
for arg in args:
time_dict.append(arg)
prayer_dict = {}
for a,b in zip(name_dict, time_dict):
prayer_dict[a] = b
return prayer_dict
# get today's prayer time
def getTodayPrayerTime():
with open(filename, 'U') as csvfile:
spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in spamreader:
today_date = current.strftime('%d/%m/%Y')
if (row[0].split(',')[0] == today_date) :
print getDictOutput(row[0].split(','))
getTodayPrayerTime()
# get monthly prayer times
def getMonthlyPrayerTime():
with open(filename, 'U') as csvfile:
spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in spamreader:
if 'asr_begins' in row[0].split(','):
continue
print getDictOutput(row[0].split(','))
getMonthlyPrayerTime()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment