magarena/scripts/extract_candidates.awk

63 lines
1011 B
Awk
Raw Permalink Normal View History

BEGIN {
FS = "\t"
OFS = "\t"
ORS = ""
}
FILENAME ~ /mtg-data/ {
2012-10-10 07:03:56 -07:00
if ($1 in score) {
found[$1] = 1;
cnt++
}
if ($1 in found && !($1 in ignore)) {
print score[$1] "\t"
print "NOTE:"comment[$1] "\t"
print "NAME:"$1 "\t"
print "TEXT:" "\t"
while ($0 != "") {
getline
print $0 "\t"
}
print "\n"
2013-03-03 04:52:49 -08:00
} else {
while ($0 != "") {
getline
}
}
2012-10-10 07:03:56 -07:00
next
}
FILENAME ~ /unimplementable/ {
ignore[$1] = 1
2012-10-10 07:03:56 -07:00
next
}
FILENAME ~ /cards\/groovy.txt/ {
comment[$1] = "groovy"
next
}
{
if (NF == 1) {
score[$1] = 1
} else if (NF == 2) {
score[$2] = $1
comment[$2] = $3
} else {
print "unsupported format"
exit 1
}
}
END {
ORS = "\n"
print "found " cnt " cards" > "/dev/stderr"
for (i in score) {
if (!(i in found)) {
print i " not found" > "/dev/stderr"
}
}
}