Pywikibot tutorial

According to the Wikidata wiki pywikibot tutorial: winter storage

I'm not actually that interested in winter storage so I'll just play through this tutorial with few variations, except where I want to learn how Python works.

from collections import OrderedDict
import pywikibot
import csv

site = pywikibot.Site("en", "wikipedia")
page = pywikibot.Page(site, "Douglas Adams")
item = pywikibot.ItemPage.fromPage(page)

item_dict = item.get()
lbl_dict = item_dict["labels"]
lbl_sdict = OrderedDict(sorted(lbl_dict.items())) #Sorting the dictionary

with open("output_douglas.csv", "w", newline="", encoding='utf-8') as csvf:
    fields = ["lang-code", "label"]
    writer = csv.DictWriter(csvf, fieldnames=fields)
    writer.writeheader()
    for key in lbl_sdict:
        writer.writerow({"lang-code": key, "label": lbl_sdict[key]})

The code above doesn't produce any output. Instead it writes to a file which can be found in the same directory as this Jupyter notebook.

import json
item_dict = item.get()
lbl_dict = item_dict["labels"] #get the item again to destroy the sorting done last round
with open("output_douglas.json", "w", newline="", encoding='utf-8') as jsonf:
    json.dump(lbl_dict, jsonf, ensure_ascii=False, sort_keys=True) #the last option sorts it
with open("output_douglas_nosort.json", "w", newline="", encoding='utf-8') as jsonf:
    json.dump(lbl_dict, jsonf, ensure_ascii=False, sort_keys=False) #no sorting

(Not bothering with SQLite because not gonna use it anytime soon.)