Skip to content

Instantly share code, notes, and snippets.

@mattash
Created January 7, 2011 18:37
Show Gist options
  • Save mattash/769890 to your computer and use it in GitHub Desktop.
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
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