For an event schedule I’d like to take date from a csv table and generate sections by location and within those sections list all events ordered by date.
Suppose I have the following .csv:
title,date,city
Event1,2025-10-11T19:00,"Amsterdam"
Event2,2025-10-01T15:00,"Amsterdam"
Event3,2025-10-17T19:00,"New York"
Event4,2025-10-01T19:30,"New York"
...
I’d like to get a document like this
= Amsterdam
== 01/10/2025
- Event2
- ...
-
== 11/10/2025
- Event 1
- ...
= New York
...
I’ve already imported the csv and parsed the times into datetime objects so I have an array of dicts like this:
events
(
(
title: "Event2",
date: datetime(
year: 2025,
month: 10,
day: 1,
hour: 15,
minute: 0,
second: 0,
),
city: "Amsterdam",
),
(
title: "Event4",
...
)
From this also was able to generate an array of unique cities
#let cities = ()
#for event in events{
cities.push(event.at("city"))
}
#let unique_cities = cities.dedup().sorted()
and use it to generate the city sections
#for unique_city in unique_cities{
set page(...
)
// Section Heading for each city
align(center, text(heading(unique_city), size: 1.5em))
// Get events for unique city and show them using the event template
for (title, date, city) in events {
if city == unique_city{
show: event.with(title: title, date: date, city: city)}
}
}
Now I am stuck at filtering events by city and then generating subsections for unique dates within a city. Also I suspect I’m doing this all in a very roundabout way. If someone could point me in the right direction I’d be grateful.