Created
January 7, 2011 18:37
-
-
Save mattash/769890 to your computer and use it in GitHub Desktop.
A gawk script to process a text file of Armenian Church Lectionary dates
This file contains 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
BEGIN { print "days:" } | |
/ ([a-zA-Z]*)/ { | |
monthtext = $2; | |
m["January"] = 1; | |
m["February"] = 2; | |
m["March"] = 3; | |
m["April"] = 4; | |
m["May"] = 5; | |
m["June"] = 6; | |
m["July"] = 7; | |
m["August"] = 8; | |
m["September"] = 9; | |
m["October"] = 10; | |
m["November"] = 11; | |
m["December"] = 12; | |
month = m[$2]; | |
} | |
/^([0-9]*)[ \t\n]+([[:alnum:] ]+)\.[ ]+([[:alnum:][:space:]\-\.\,\"\'\)\(]+)\.[ ]+(.*)/ { | |
date = gensub(/([0-9]*)[ \t\n]+([[:alnum:] ]+)\.[ ]+([[:alnum:][:space:]\-\.\,\"\'\)\(]+)\.[ ]+(.*)/,"\\1","g"); | |
day = gensub(/([0-9]*)[ \t\n]+([[:alnum:] ]+)\.[ ]+([[:alnum:][:space:]\-\.\,\"\'\)\(]+)\.[ ]+(.*)/,"\\2","g"); | |
name = gensub(/([0-9]*)[ \t\n]+([[:alnum:] ]+)\.[ ]+([[:alnum:][:space:]\-\.\,\"\'\)\(]+)\.[ ]+(.*)/,"\\3","g"); | |
passages = gensub(/([0-9]*)[ \t\n]+([[:alnum:] ]+)\.[ ]+([[:alnum:][:space:]\-\.\,\"\'\)\(]+)\.[ ]+(.*)\./,"\\4","g"); | |
# Set year | |
year = 2011; | |
# Split passages into Array | |
split(passages,a,", "); | |
reading = ""; | |
for (item in a) { | |
reading = reading "\n - passage: "a[item]; | |
} | |
#output | |
printf " - title: %s\n date: %s-%d-%s\n readings:%s\n", name, month, date, year, reading; | |
null } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment