This is the varia library website work in progress.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

65 lines
1.7 KiB

"""This parses the varlib.csv but only in a way
that is actually useful for the site"""
import csv
import os
script_dir = os.path.dirname(__file__)
def parsecsv():
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
with libcsv:
csv_as_dict = csv.DictReader(libcsv)
return csv_as_dict
def getpublications():
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
with libcsv:
csv_as_dict = csv.DictReader(libcsv)
publications = {}
for row in csv_as_dict:
year = row["Year"]
if not year:
year = "Unknown"
pubinfo = {
"Title": row["Publication"],
"Author": row["Author"],
"Type": row["Type"].lower(),
"Year": year,
}
publications[row["Id"]] = pubinfo
return publications
def gettypes():
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
with libcsv:
csv_as_dict = csv.DictReader(libcsv)
listoftypes = []
for row in csv_as_dict:
lowertype = row["Type"].lower()
if lowertype not in listoftypes:
listoftypes.append(lowertype)
return listoftypes
def getyears():
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
with libcsv:
csv_as_dict = csv.DictReader(libcsv)
listofyears = []
for row in csv_as_dict:
uniqueyear = row["Year"]
if not uniqueyear:
uniqueyear = "Unknown"
if uniqueyear not in listofyears:
listofyears.append(uniqueyear)
listofyears.sort()
return listofyears
# test = getpublications()
# for ids, pubinfo in test.items():
# print(pubinfo["Title"])