Skip to content

Commit

Permalink
Update compile_schedule.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremymanning authored Jul 18, 2024
1 parent fdfb437 commit 044fab2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions compile_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,9 @@ def replace(match):
emoji_pattern = re.compile('|'.join(re.escape(key) for key in emoji_mapping.keys()))
return emoji_pattern.sub(replace, text)

def remove_last_lines(lines, n):
count = 0
for i in range(len(lines) - 1, -1, -1):
if lines[i].strip() != '':
count += 1
if count == n:
return lines[:i]
return lines
def remove_first_and_last_lines(lines, n, m):
non_whitespace_lines = [line for line in lines if line.strip()]
return non_whitespace_lines[n:-m]

# Load events
events_df = pd.read_csv('events.tsv', delimiter='\t')
Expand All @@ -76,8 +71,8 @@ def remove_last_lines(lines, n):
non_whitespace_lines = [line.strip() for line in event_content if line.strip()]
event_title = non_whitespace_lines[1] if len(non_whitespace_lines) > 1 else row["Event Name"]

# Remove the first line (title) and the last two non-whitespace lines
event_content = remove_last_lines(event_content, 2)[2:]
# Remove the first and last two non-whitespace lines
event_content = event_content = remove_first_and_last_lines(event_content, 2, 2)

# Replace placeholders with actual values
event_content = ''.join(event_content).replace('{DATE}', row['Date']).replace('{TIME}', row['Time']).replace('{LOCATION}', row['Location'])
Expand Down

0 comments on commit 044fab2

Please sign in to comment.