-- Extract data from CLDR data file likelySubtags.xml -- Relevant tags: -- Assign script arguments and check validity xmlFileName = "unicode/likelySubtags.xml" sqlFileName = "temp/uni_loadlikely.sql" -- Open files xmlInput = assert(io.open(xmlFileName, "r")) xmlData = xmlInput:read("*all") sqlFile = assert(io.open(sqlFileName, "w")) -- Write SQL file header sqlFile:write("create table if not exists uni_likelysubtags (tagfrom char, tagto char, primary key (tagfrom));\n") sqlFile:write("delete from uni_likelysubtags;\n") sqlFile:write("begin;\n") -- Extract data from XML -- Replace underscore by hyphen for w in string.gmatch(xmlData, "(.-)") do for tagFrom,tagTo in string.gmatch(w, ".-