Last active
August 29, 2015 13:56
-
-
Save webbyfox/9102480 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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