Skip to content

Instantly share code, notes, and snippets.

@typebrook
Created February 20, 2023 04:29
Show Gist options
  • Save typebrook/62e92b2d531b878fe85efbab3f550485 to your computer and use it in GitHub Desktop.
Save typebrook/62e92b2d531b878fe85efbab3f550485 to your computer and use it in GitHub Desktop.
Print ics parts of Taiwan holidays from open data #gov #ics #icalendar
.ONESHELL:
# https://data.gov.tw/dataset/14718
data.csv:
curl -L 'https://www.dgpa.gov.tw/FileConversion?filename=dgpa/files/202206/d52179b9-5e82-489b-86fd-716e959bfa5c.csv&nfix=&name=112%e5%b9%b4%e4%b8%ad%e8%8f%af%e6%b0%91%e5%9c%8b%e6%94%bf%e5%ba%9c%e8%a1%8c%e6%94%bf%e6%a9%9f%e9%97%9c%e8%be%a6%e5%85%ac%e6%97%a5%e6%9b%86%e8%a1%a8.csv' | \
iconv -f BIG-5 -t UTF-8 | \
dos2unix >$@
clean: data.csv
sed -i '1d; /,$$/d' $^
.SILENT: 2023.ics
2023.ics: data.csv
i=160
tr ',' '\t' <data.csv | \
while read DATE WEEKDAY VACATION NAME; do
echo BEGIN:VEVENT
echo UID:tai_$$(( i++ ))
echo DTSTART:$${DATE}T000000Z
echo DTEND:$${DATE}T235959Z
echo SUMMARY:$${NAME}
echo DESCRIPTION:$${NAME}
echo END:VEVENT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment