Export Topic Labels

In [1]:
import os
import pandas as pd
import gspread
from oauth2client.service_account import ServiceAccountCredentials
In [2]:
scope = ['https://spreadsheets.google.com/feeds']
secrets = "/Users/jeriwieringa/Dissertation/dev/code/secrets/dissertation-881847769b13.json"
credentials = ServiceAccountCredentials.from_json_keyfile_name(secrets, scope)
In [3]:
gc = gspread.authorize(credentials)
In [4]:
dts = gc.open('Topic Labels').sheet1
frame = pd.DataFrame(dts.get_all_records())
In [5]:
frame[:10]
Out[5]:
browser_topic_id mallet_topic_id topic_category topic_label topic_prevalence_overall topic_words
0 1 0 missions Missions (Canvassing Work) 0.02981 book canvasser order canvassing brother week s...
1 2 1 nutrition Nutrition (Recipes) 0.00927 cup water bread egg add cream salt flour milk ...
2 3 2 scan_errors Scan Errors (OCR Errors) 0.03660 ing tion ment sign ness com ter tions great en...
3 4 3 social_commentary Social Commentary (Suffering and Death from Vi... 0.03036 death man blood men like life hand victim poor...
4 5 4 spiritual_growth Spiritual Growth (Christian Life - Perseverance) 0.02033 shall lord unto faith thing hope trial christ ...
5 6 5 sermons Sermons (Religious Practice) 0.10352 thing know think way man want let doe right go...
6 7 6 bible Bible (Stories from Daniel and Babylonian Capt... 0.01276 king daniel babylon jerusalem lord kingdom neb...
7 8 7 scan_errors Scan Errors (OCR Errors 2) 0.04291 ing lie review end herald ill tie ile tho good...
8 9 8 spiritual_growth Spiritual Growth (Christian Behavior) 0.01902 prayer lord heart spirit blessing let church m...
9 10 9 reports_on_the_cause Reports on the Cause ("Progress of the Cause") 0.01000 meeting church brother lord sabbath truth held...
In [6]:
topic2id = pd.Series(frame.topic_label.values,index=frame.browser_topic_id)
In [7]:
dict_view = {}
for index, value in topic2id.iteritems():
    dict_view["{}".format(index)] = "{}".format(value)
In [8]:
import json
In [9]:
print(json.dumps(dict_view, indent=2, sort_keys=True))
{
  "1": "Missions (Canvassing Work)",
  "10": "Reports on the Cause (\"Progress of the Cause\")",
  "100": "Theology (Christ and salvation)",
  "101": "Signs of the Times (Astronomy)",
  "102": "Conference Proceedings (Discussions)",
  "103": "Piety (Testimonies and Letters)",
  "104": "Theology (Sabbath Keeping)",
  "105": "Education (Educational Theory)",
  "106": "Meeting Reports (SDA Institutions)",
  "107": "Advertisements (Printing)",
  "108": "Health (Sanitariums - West Coast)",
  "109": "Advertisements (Subscriptions)",
  "11": "Theology (The Soul)",
  "110": "Social Commentary (Labor Organization and Disputes)",
  "111": "Missions (Prison Ministries)",
  "112": "Stories (Moralistic Stories)",
  "113": "Piety (Ocean as metaphor for life) ",
  "114": "Education (SDA Colleges)",
  "115": "Theology (Sin)",
  "116": "Stories (Health-related)",
  "117": "Reports on the Cause (Field Reports)",
  "118": "Eschatology (Parable of Bridegroom and Tarrying Time)",
  "119": "Missions (News and Announcements)",
  "12": "Stories (Children's)",
  "120": "Apologetics (Geology and Evolution)",
  "121": "Advertisements (Pacific Press Books)",
  "122": "General Interest (Population and Statistics)",
  "123": "Nutrition (Grains)",
  "124": "Organization (Statistical Summaries)",
  "125": "Organization (Place names)",
  "126": "Reports on the Cause (History of SDA Work)",
  "127": "Bible (New Testament Lessons)",
  "128": "Missions",
  "129": "Conference Proceedings (Resolutions and Summaries)",
  "13": "Spiritual Growth (Christian Virtue - Development)",
  "130": "Apologetics (Other Religions)",
  "131": "Prophecy (Figures of Revelation)",
  "132": "Theology (Sabbath Keeping)",
  "133": "Organization (Funds and Figures - Pacific Union)",
  "134": "Advertisements (SDA Publications - early)",
  "135": "History (Sunday Observance)",
  "136": "Education (Teaching Plans)",
  "137": "Health (Rest)",
  "138": "Church & State (Religious Amendments and National Reform Association)",
  "139": "Advertisements",
  "14": "Sermons (Salvation Narrative)",
  "140": "Education (Sabbath Lessons)",
  "141": "Theology (the Fall)",
  "142": "Signs of the Times (Crime and Immorality)",
  "143": "Missions (South America)",
  "144": "Health (Ventilation)",
  "145": "Organization (Church Finances)",
  "146": "Eschatology (Sanctuary Doctrine)",
  "147": "Organization (Funds and Figures - Lake Union)",
  "148": "Nature (Animals)",
  "149": "Reports on the Cause (Building Projects)",
  "15": "Reports on the Cause (News and Field Reports)",
  "150": "Social Commentary (Commerce and Money)",
  "151": "Obituaries (Death Notices)",
  "152": "Obituaries (Death Notices)",
  "153": "Theology (Prayer)",
  "154": "Church & State (Arguments against Sabbath Laws)",
  "155": "Advertisements (Sanitariums)",
  "156": "Theology (the Sabbath Question)",
  "157": "Advertisements (Books and Literature)",
  "158": "Advertisements (Premium Bibles)",
  "159": "Signs of the Times (\"Catholic Threat\")",
  "16": "Politics (Religious Freedom)",
  "160": "Theology (Baptism and Sacraments)",
  "161": "Health (Habits)",
  "162": "Theology (Seventh-day Sabbath)",
  "163": "Organization (Lists of Donors and People)",
  "164": "Signs of the Times (War)",
  "165": "Stories (Moralistic Story - Family)",
  "166": "Stories (Theological)",
  "167": "Church & State (Sabbath Laws)",
  "168": "Theology (Ten Commandments)",
  "169": "Social Commentary (Temperance)",
  "17": "Piety (Poetry)",
  "170": "Spiritual Growth (Overcoming Temptation and Sin)",
  "171": "Eschatology (Events of the Last Days)",
  "172": "Spiritual Growth (Calls for Charity)",
  "173": "History (History in the Light of Prophecy)",
  "174": "Organization (Notices of Meetings and Appointments)",
  "175": "Nutrition (Foods and Recipes)",
  "176": "Organization (Columbia Union - Ohio - Activity Reports)",
  "177": "Missions (Africa)",
  "178": "Religious Commentary (Preaching and Ministry)",
  "179": "Bible (Quotations)",
  "18": "General Interest (News and Notes)",
  "180": "Signs of the Times (Global Unrest)",
  "181": "Social Commentary (Testimonies and Moral Commentary - largely EGW)",
  "182": "General Interest (Natural Disasters)",
  "183": "Eschatology (Description of Second Coming)",
  "184": "Health (Alcohol and Disease)",
  "185": "Health (Dangers of Alcohol)",
  "186": "Nature (Flora and Fauna)",
  "187": "Advertisements (Life Boat)",
  "188": "Health (Regular Medicine)",
  "189": "Bible (New Testament - Apostles)",
  "19": "Education (Medical Training Programs)",
  "190": "Theology (Righteousness by Faith)",
  "191": "Bible (Old Testament - Prophets)",
  "192": "Bible (Ten Commandments - Quoted)",
  "193": "Transportation (Trains)",
  "194": "Correspondence (Letters from Children)",
  "195": "Nutrition (Food - Meat)",
  "196": "Piety (Religious Comfort)",
  "197": "Theology (Holy Spirit)",
  "198": "Spiritual Growth (Christian Virtue)",
  "199": "Missions (Missions Work)",
  "2": "Nutrition (Recipes)",
  "20": "Advertisements (Transportation)",
  "200": "Eschatology (Second Coming)",
  "201": "Community News (Indiana)",
  "202": "Stories (Religious Stories)",
  "203": "Education (Farming and Agriculture)",
  "204": "Advertisements (Notices and Appointments)",
  "205": "Health (Eyes)",
  "206": "Missions (Sabbath School and Home Department)",
  "207": "Bible (Parables - Sower)",
  "208": "Advertisements (Bible Readers)",
  "209": "Education (Crafting Instructions)",
  "21": "Organization (Church Organization)",
  "210": "Reports on the Cause (\"Progress of the Cause\"  - Reports on Local Reception)",
  "211": "Church & State (Religion Legislation and the Courts)",
  "212": "History (Reformation)",
  "213": "Organization (Report of Offerings)",
  "214": "Apologetics (Rebuttals and Responses)",
  "215": "Religious Commentary (Death)",
  "216": "Prophecy (Interpreting Dates and Time)",
  "217": "Health (Digestive System)",
  "218": "Missions (India)",
  "219": "Organization (Financial Report)",
  "22": "Politics (Principles of the Republic and their Violation)",
  "220": "Advertisements (Periodicals)",
  "221": "Missions (Home Missions)",
  "222": "Church & State (Religion in Public Education)",
  "223": "Bible (Quotations)",
  "224": "Community News (Lake Union & Tithe Reports)",
  "225": "Stories (Missionary stories)",
  "226": "Education",
  "227": "Community News (Southern Union)",
  "228": "Missions (Foreign Missions)",
  "229": "Meeting Reports (Tract and Missionary Societies)",
  "23": "Theology (Law and the New Testament)",
  "230": "Spiritual Growth (Christian Life)",
  "231": "Conference Proceedings (Resolutions Adopted)",
  "232": "Spiritual Growth (Christian Virtue)",
  "233": "Community News (Lake Union)",
  "234": "Reports on the Cause (\"Progress of the Cause\" - Report of Labor)",
  "235": "Theology (Christology)",
  "236": "Stories (Animals)",
  "237": "Periodicals (Publication Information - Michigan Titles)",
  "238": "Spiritual Growth (Christian Virtue)",
  "239": "Organization (Constitutions, Bylaws, and Articles of Incorporation)",
  "24": "Theology (Atonement)",
  "240": "Education (Lesson Plans for Sabbath Study)",
  "241": "Bible (Old Testament)",
  "242": "Missions (Of Missionary Ships)",
  "243": "Signs of the Times (Enforcement of Sunday Laws)",
  "244": "Spiritual Growth (Christian Education)",
  "245": "Periodicals (Washington, D.C. Titles)",
  "246": "Nutrition (Food)",
  "247": "Health (Dress Reform)",
  "248": "Organization (Divisions)",
  "249": "Missions (Missions Department)",
  "25": "Theology (Tithing)",
  "250": "Health (Exercise)",
  "26": "Organization (Notices of Meetings)",
  "27": "Religious Commentary (Spiritualism)",
  "28": "Signs of the Times (\"Eastern Question\")",
  "29": "Meeting Reports (Accounts of Camp Meetings and Conferences)",
  "3": "Scan Errors (OCR Errors)",
  "30": "Advertisements (Publications) ",
  "31": "Politics (War and the State)",
  "32": "Health (Disease)",
  "33": "Missions (Canvassing Workers)",
  "34": "Theology (Great Controversy)",
  "35": "Advertisements (SDA Publications - mid)",
  "36": "Bible (Translations)",
  "37": "Theology (Sin)",
  "38": "Religious Commentary (Descriptions of Heaven)",
  "39": "Theology (God and Man)",
  "4": "Social Commentary (Suffering and Death from Vices)",
  "40": "Signs of the Times (Social Unrest)",
  "41": "Theology (Bible Interpretation)",
  "42": "Nutrition (Vegetables and Produce)",
  "43": "Church & State (Opposition to Religious Legislation)",
  "44": "Periodicals (Agencies for Magazine Ordering)",
  "45": "Missions (Chicago Mission)",
  "46": "Prophecy (Figures of Daniel)  ",
  "47": "Transportation (Train Travel)",
  "48": "Health (Infant Care)",
  "49": "Correspondence",
  "5": "Spiritual Growth (Christian Life - Perseverance)",
  "50": "Periodicals (Book Sales and Publishing Business)",
  "51": "Spiritual Growth (Calls to Christian Virtue - EGW)",
  "52": "Eschatology (Spreading the Third Angel's Message)",
  "53": "Bible (Parables - Wealth)",
  "54": "Bible (Parables - Talents)",
  "55": "Meeting Reports (Lake Union Conferences)",
  "56": "Community News (Columbia Union)",
  "57": "History (Historical Evidence for Reliability of Bible)",
  "58": "History (Religious Liberty in Anglo Political History)",
  "59": "Organization (The Chicago Mission)",
  "6": "Sermons (Religious Practice)",
  "60": "Correspondence (Letters from Readers)",
  "61": "Reports on the Cause (Account of Labors)",
  "62": "Meeting Reports (Descriptions of Denominational Events)",
  "63": "Nature (Landscapes)",
  "64": "Missions (Asia)",
  "65": "Health (Cleaning - teeth and household)",
  "66": "Education (Reading Course)",
  "67": "Nutrition (Diet)",
  "68": "Missions (Calls to Home Missions - EGW)",
  "69": "Advertisements (Health)",
  "7": "Bible (Stories from Daniel and Babylonian Captivity)",
  "70": "Organization (Funds - Harvest Ingathering)",
  "71": "Missions (Tract Distribution)",
  "72": "Meeting Reports (Southern Union Conferences)",
  "73": "Theology (the Dead)",
  "74": "Apologetics (Debates)",
  "75": "Missions (Foreign Missions)",
  "76": "General Interest (Military Culture)",
  "77": "General Interest (Architecture)",
  "78": "Bible (Old Testament Lessons)",
  "79": "Advertisements (Goods and Services)",
  "8": "Scan Errors (OCR Errors 2)",
  "80": "Stories (Character Development - Boys)",
  "81": "Bible (Biblical Exegesis)",
  "82": "Stories (Moralistic Stories - girls)",
  "83": "Organization (Travel Arrangements and Organization)",
  "84": "Social Commentary (Marriage and Divorce)",
  "85": "Spiritual Growth (Virtuousness and Industry)",
  "86": "Social Commentary (Amusement and Sport)",
  "87": "Signs of the Times (Growing Iniquity as in Days of Noah)",
  "88": "Advertisements (Subscription)",
  "89": "Bible (New Testament)",
  "9": "Spiritual Growth (Christian Behavior)",
  "90": "Social Commentary (Immigration and Non-English Language Concerns)",
  "91": "Missions (Relief for Indigent Children)",
  "92": "Advertisements (Music and Instruments)",
  "93": "Theology (Fate of the Wicked at Second Coming)",
  "94": "Health (Tuberculosis)",
  "95": "Spiritual Growth (Manners and Cheerfulness)",
  "96": "Health (Hydrotherapy)",
  "97": "General Interest (News and Catastrophic Events)",
  "98": "Health (Q & A)",
  "99": "Health (Coffee Tea Tobacco)"
}
In [ ]: