Keyscrape to SQLite converter

Keyscrape to SQLite converter

An awk script used to convert tab-delimited files from keyscrape into SQLite code. The NOCASE parameter is used in the keyword field. This should allow for both FOO and foo to be the same keyword.

Use it in the following way:

weewiki keyscrape > keys.txt
./keys2db < keys.txt | sqlite3 keys.db

<<keys2db>>=
#!/usr/bin/awk -f
BEGIN {
    FS="\t"
    print("DROP TABLE IF EXISTS keywords;")
    print("CREATE TABLE keywords(page TEXT, keyword TEXT COLLATE NOCASE, line INTEGER);")
    print("BEGIN;");
}

{
    print "INSERT INTO keywords(page, keyword, line) " \
    "VALUES(\""$1"\",\""$2"\","$3");"
}
END {
    print("COMMIT;");
}

home | index