I make a few assumptions that you should make sure are true:
-
You have a mental idea of the user who will be using your website and the core problem they're trying to solve, e.g., "academics looking for statistics about hunting injuries" or "concerned citizens who want to know the current population of Guantanamo Bay detainees."
-
You have put some thought into how your website can solve these problems. Remember: Keep your features simple. A perfectly acceptable version of your site could be "read the descriptions of each hunting accident to see the conditions under which people have been injured."
-
You can express these thoughts in terms of pages that show both the near and the far view, e.g., give some understanding of the whole but allow a user to dive in on details as appropriate.
With these assumptions in mind, you should feel comfortable enough with the contents of your data set to start working on laying out your web site. Perhaps you'd like to have a grid of hunting injuries. Or a list of detainees. Remember that you'll want to pick something that works well on a phone and a laptop as well as on a gigantic computer screen.
Your homework, then, is to begin applying the grid system from Materialize to your templates. I recommend starting with the index. Cards are also particularly interesting and might solve some of your problems nicely.
WARNING: This will be somewhat frustrating. It will be the first time your hand-writing code (or pasting / modifying from Materialize) and it will try your patience. I recommend doing this when you've got a nice cup of tea and some good instrumental music going.
It might be the case that you'd like to focus your site on a subset of your data. Perhaps you're interested only in detainees that have died while in captivity. Or you're interested in only hunting accidents where the victims are below the age of 25.
Let's say you have a colum in your spreadsheet called died_in_custody
and you would like to find all rows where the value is TRUE
.
Here is a pattern for getting just the data you want.
This is a code snippet you might want to use in your app.py
:
rows = [x for x in list(csv.DictReader(readfile)) if x['died_in_custody'] == "TRUE"]
This device is called a list comprehension. Here's a pseudo-code explanation of what's going on:
rows = [a_thing for a_thing in my_big_list where a_thing['column_name'] == a_value]
There are many comparison operators you can use.
==
means "equals." You can use this if you know exactly what you want the value to be.<
means "less than". You can use this if the value is an integer or a float and you compare to an integer or a float.
There are more operators here you can use.
Here's an example where we find all hunting accidents where the injury is fatal and the victim was less than or equal to 25:
rows = [x for x in list(csv.DictReader(readfile)) if x['injury'] == "FATAL" and x['vage'] <= 25]
You can use and
if you have two or more conditions and all must be true to satisfy your query. You can use or
if you have two or more conditions and one or more must be true to satisfy your query.
The example above will return only those rows where the injury was fatal and the victim's age was less than or equal to 25.
But if you wrote it like this:
rows = [x for x in list(csv.DictReader(readfile)) if x['injury'] == "FATAL" or x['vage'] <= 25]
It will return all rows where the injury was fatal and all rows where the victim's age was less than or equal to 25. It will not be limited to just those rows where both things are true.
Remember, you'll need to restart your web application (the green button in the Web tab) after making these changes.
Email me if you run into trouble and I'll help out! But make sure you put in some time trying to fix your own problem before calling in an airstrike from me. You'll need to build proficiency in fixing your own errors and this is a great time to start.