mirror of
https://github.com/karl0ss/downgrangefixtures_ical.git
synced 2025-05-10 00:41:31 +01:00
code cleanup
This commit is contained in:
parent
9130aaa8af
commit
c4d821f43d
52
fixtures.ics
52
fixtures.ics
@ -2,119 +2,119 @@ BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:Down Grange Pumas Fixtures
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Curley Park Rangers U12 Mambas
|
||||
SUMMARY:Down Grange U12 Pumas VS Curley Park Rangers U12 Mambas
|
||||
DTSTART:20231202T093000
|
||||
DTEND:20231202T113000
|
||||
DTSTAMP:20231202T093000Z
|
||||
UID:1eaa0801-c81f-4135-9793-8e8acc30f3b4
|
||||
UID:84d25507-da65-4b16-93b1-5f489629a8c3
|
||||
DESCRIPTION:Arrive by - 2023-12-02 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Petersfield Town U12 Revolution vs Down Grange U12 Pumas
|
||||
SUMMARY:Petersfield Town U12 Revolution VS Down Grange U12 Pumas
|
||||
DTSTART:20231209T093000
|
||||
DTEND:20231209T113000
|
||||
DTSTAMP:20231209T093000Z
|
||||
UID:560fb6da-0638-4c7d-af09-81dae4a47aca
|
||||
UID:5e1bba88-8c59-4308-8e44-4921ec36f030
|
||||
DESCRIPTION:Arrive by - 2023-12-09 09:00:00
|
||||
LOCATION:TARO LEISURE CENTRE 1
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Mytchett Athletic U12 Hawks vs Down Grange U12 Pumas
|
||||
SUMMARY:Mytchett Athletic U12 Hawks VS Down Grange U12 Pumas
|
||||
DTSTART:20231216T093000
|
||||
DTEND:20231216T113000
|
||||
DTSTAMP:20231216T093000Z
|
||||
UID:65d1626b-cc20-4186-b381-70f35560efff
|
||||
UID:b1c2ea4d-3309-40a5-9f17-dab900dd8c0b
|
||||
DESCRIPTION:Arrive by - 2023-12-16 09:00:00
|
||||
LOCATION:HARPERS RECREATION GROUND
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Tongham U12
|
||||
SUMMARY:Down Grange U12 Pumas VS Tongham U12
|
||||
DTSTART:20240106T093000
|
||||
DTEND:20240106T113000
|
||||
DTSTAMP:20240106T093000Z
|
||||
UID:e8780313-5958-4e33-b6a4-e09caba9c1e9
|
||||
UID:884d9074-b97a-400f-962b-f40676031049
|
||||
DESCRIPTION:Arrive by - 2024-01-06 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Farnham Town U12 Panthers vs Down Grange U12 Pumas
|
||||
SUMMARY:Farnham Town U12 Panthers VS Down Grange U12 Pumas
|
||||
DTSTART:20240113T093000
|
||||
DTEND:20240113T113000
|
||||
DTSTAMP:20240113T093000Z
|
||||
UID:e8dc7386-d238-4004-8462-d6b01fc6ed40
|
||||
UID:ceb1a9d2-a3f1-4210-abe7-f14faa45fe76
|
||||
DESCRIPTION:Arrive by - 2024-01-13 09:00:00
|
||||
LOCATION:MONKTON LANE 5v5 1
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Mytchett Athletic U12 Hawks
|
||||
SUMMARY:Down Grange U12 Pumas VS Mytchett Athletic U12 Hawks
|
||||
DTSTART:20240127T093000
|
||||
DTEND:20240127T113000
|
||||
DTSTAMP:20240127T093000Z
|
||||
UID:e955690f-88c5-4e53-bf67-740ef9aef3f3
|
||||
UID:133b7ce6-62a5-4143-8fbf-7137fe93ccda
|
||||
DESCRIPTION:Arrive by - 2024-01-27 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Fernhurst Sports U12 Terriers vs Down Grange U12 Pumas
|
||||
SUMMARY:Fernhurst Sports U12 Terriers VS Down Grange U12 Pumas
|
||||
DTSTART:20240203T093000
|
||||
DTEND:20240203T113000
|
||||
DTSTAMP:20240203T093000Z
|
||||
UID:8277f05b-b42c-471a-af1c-30fc0838bbf0
|
||||
UID:484e512b-61d5-4c02-9035-3c874c9d6d90
|
||||
DESCRIPTION:Arrive by - 2024-02-03 09:00:00
|
||||
LOCATION:FERNHURST RECREATION GROUND
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Aldershot B&G U12 Lions
|
||||
SUMMARY:Down Grange U12 Pumas VS Aldershot B&G U12 Lions
|
||||
DTSTART:20240210T093000
|
||||
DTEND:20240210T113000
|
||||
DTSTAMP:20240210T093000Z
|
||||
UID:d74edce9-fecf-4355-8931-15865efcbb92
|
||||
UID:fa5969f3-f5ac-4220-b5d8-78a7e91390d0
|
||||
DESCRIPTION:Arrive by - 2024-02-10 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Petersfield Town U12 Revolution
|
||||
SUMMARY:Down Grange U12 Pumas VS Petersfield Town U12 Revolution
|
||||
DTSTART:20240217T093000
|
||||
DTEND:20240217T113000
|
||||
DTSTAMP:20240217T093000Z
|
||||
UID:989e9442-8c17-4638-ad80-55e79913b5be
|
||||
UID:29db21b2-e403-469d-a81a-77b1cf6d823b
|
||||
DESCRIPTION:Arrive by - 2024-02-17 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Curley Park Rangers U12 Mambas vs Down Grange U12 Pumas
|
||||
SUMMARY:Curley Park Rangers U12 Mambas VS Down Grange U12 Pumas
|
||||
DTSTART:20240224T093000
|
||||
DTEND:20240224T113000
|
||||
DTSTAMP:20240224T093000Z
|
||||
UID:57c1422a-5f50-460d-8048-e78489e22e22
|
||||
UID:e5ef6621-6fb1-4ef1-a325-34fad70c3af4
|
||||
DESCRIPTION:Arrive by - 2024-02-24 09:00:00
|
||||
LOCATION:LIGHTWATER RECREATION GROUND
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Tongham U12 vs Down Grange U12 Pumas
|
||||
SUMMARY:Tongham U12 VS Down Grange U12 Pumas
|
||||
DTSTART:20240302T093000
|
||||
DTEND:20240302T113000
|
||||
DTSTAMP:20240302T093000Z
|
||||
UID:34c8480c-3345-41cc-a998-98ca93f63be6
|
||||
UID:786068e5-9f90-4eea-a7ce-2acd6182c986
|
||||
DESCRIPTION:Arrive by - 2024-03-02 09:00:00
|
||||
LOCATION:POYLE ROAD RECREATION GROUND #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Farnham Town U12 Panthers
|
||||
SUMMARY:Down Grange U12 Pumas VS Farnham Town U12 Panthers
|
||||
DTSTART:20240309T093000
|
||||
DTEND:20240309T113000
|
||||
DTSTAMP:20240309T093000Z
|
||||
UID:1886776c-1ae8-4a65-a2c0-74b690b19091
|
||||
UID:d911aacb-2b79-4cbc-a7bc-daaeff14be60
|
||||
DESCRIPTION:Arrive by - 2024-03-09 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Down Grange U12 Pumas vs Fernhurst Sports U12 Terriers
|
||||
SUMMARY:Down Grange U12 Pumas VS Fernhurst Sports U12 Terriers
|
||||
DTSTART:20240316T093000
|
||||
DTEND:20240316T113000
|
||||
DTSTAMP:20240316T093000Z
|
||||
UID:659caaf8-9691-4a52-b378-ed5daf521108
|
||||
UID:7cce63a7-a8a3-40aa-822b-78fa19070c13
|
||||
DESCRIPTION:Arrive by - 2024-03-16 09:00:00
|
||||
LOCATION:DOWN GRANGE SPORTS COMPLEX #2
|
||||
END:VEVENT
|
||||
|
30
main.py
30
main.py
@ -5,51 +5,59 @@ import uuid
|
||||
import os
|
||||
|
||||
def store_df_as_csv(df:pd.DataFrame)->None:
|
||||
"""_summary_
|
||||
"""Store dataframe as a CSV file.
|
||||
|
||||
Args:
|
||||
df (pd.DataFrame): _description_
|
||||
df (pd.DataFrame): Dataframe of fixtures.
|
||||
"""
|
||||
df.to_csv('./fixtures.csv', index=False)
|
||||
def compare_dfs(df:pd.DataFrame)->bool:
|
||||
"""_summary_
|
||||
"""Compare the latest DF with the stored DF for any changes.
|
||||
|
||||
Args:
|
||||
df (pd.DataFrame): _description_
|
||||
df (pd.DataFrame): Latest copy of fixtures in dataframe
|
||||
|
||||
Returns:
|
||||
bool: _description_
|
||||
bool: True if match, False if no match.
|
||||
"""
|
||||
df2 = pd.read_csv('./fixtures.csv')
|
||||
return df.equals(df2)
|
||||
|
||||
def write_calendar(cal:Calendar)->None:
|
||||
"""_summary_
|
||||
"""Write the cal object to an ics file.
|
||||
|
||||
Args:
|
||||
cal (Calendar): _description_
|
||||
cal (Calendar): iCalendar object with all the ics details.
|
||||
"""
|
||||
f = open(os.path.join('./', 'fixtures.ics'), 'wb')
|
||||
f.write(cal.to_ical())
|
||||
f.close()
|
||||
|
||||
def does_csv_exist()->bool:
|
||||
"""_summary_
|
||||
"""Check if the CSV file exists.
|
||||
|
||||
Returns:
|
||||
bool: _description_
|
||||
bool: True if CSV file exists, False if not.
|
||||
"""
|
||||
return os.path.isfile('./fixtures.csv')
|
||||
|
||||
def create_ical_file(df, cal)->None:
|
||||
def create_ical_file(df:pd.DataFrame, cal:Calendar)->None:
|
||||
"""Create an iCalendar file from a dataframe.
|
||||
|
||||
Args:
|
||||
df (pd.DataFrame): Dataframe of fixtures.
|
||||
cal (Calendar): iCalendar object with all the ics details.
|
||||
"""
|
||||
for index, row in df.iterrows():
|
||||
event = Event()
|
||||
print(row['Date / Time'], row['Home Team'], row['Away Team.1'], row['Venue'])
|
||||
start_date_time = datetime.strptime(row['Date / Time'], '%d/%m/%y %H:%M')
|
||||
# Set default 8am start time to normal 930 kickoff time.
|
||||
if start_date_time.hour == 8:
|
||||
start_date_time = start_date_time + timedelta(hours=1, minutes=30)
|
||||
# Arrival time is 30 mins before kickoff time.
|
||||
arrival_time = start_date_time + timedelta(minutes=-30)
|
||||
event.add('summary', str(row['Home Team']) + " vs " + str(row['Away Team.1']))
|
||||
event.add('summary', str(row['Home Team']) + f" {str(row['Unnamed: 4'])} " + str(row['Away Team.1']))
|
||||
event.add('description', f'Arrive by - {arrival_time}')
|
||||
event.add('dtstart', start_date_time)
|
||||
event.add('dtend', start_date_time + timedelta(hours=2))
|
||||
|
Loading…
x
Reference in New Issue
Block a user