Quellcode durchsuchen

Some diagnostics

master
Noelle vor 4 Jahren
Ursprung
Commit
fc32e12f3f
1 geänderte Dateien mit 33 neuen und 2 gelöschten Zeilen
  1. 33
    2
      main.py

+ 33
- 2
main.py Datei anzeigen

@@ -1,6 +1,12 @@
import requests, time, os, sys, json, csv
from bs4 import BeautifulSoup

class DataTable:
def __init__(self):
self.table = {}
self.cols = {}
self.rows = {}

class DataPocket:
def __init__(self):
self.rows = {}
@@ -226,8 +232,33 @@ def main():

r = requests.get(df.endpoint)



rjson = r.json() # this creates a Python object, not a JSON string
# in results/cells, column_option and row_option refer to the key field, not the list index
# in column_option and row_option, missing value is coded as "", but coded as "." in key field

# What are the values of "column_option" and "row_option"?
# rc = rjson["results"]["cells"]
# for i in range(10):
# print(rc[i])
# cols = []
# rows = []
# for v in rc:
# print(v.keys())
# if v["column_option"] not in cols:
# cols.append(v["column_option"])
# if v["row_option"] not in rows:
# rows.append(v["row_option"])
# print(f"Cols: {sorted(cols)}")
# print(f"Rows: {sorted(rows)}")

# This just confirms that there are, in fact, 51 states incl. DC in this query
# ro = rjson["results"]["row"]["options"]
# titles = {}
# for v in ro:
# titles[int(v["key"])] = (v["title"])
# for t in sorted(titles.keys()):
# print(f"{titles[t]}")


if __name__ == "__main__":

Laden…
Abbrechen
Speichern