aperloff/WDTSscraper

Save and read in list of people

Opened this issue · 1 comments

We should have the ability to save the list of people to a text file for later use. Additionally, the code should be able to read in this list, bypassing the parsing of the PDF files. Then this list of people can be used to draw the map. This will allow us to bypass the most time consuming portions of the code as well as to input an arbitrary list of people.

To do this we will need a way to serialize and deserialize the Person objects. The package jsons has already been added as a dependency. This way we can do the (de)serialization as:

import jsons
from laboratory import Laboratories, Laboratory
from institution import Institution
from person import Person

l = Laboratories.FNAL.value
i = Institution("University of Colorado Boulder","Boulder","CO",999,999)
p = Person("SCGSR", "Student", "Alexx", "Perloff", i, Laboratories.LBNL, "HEP", 2021)

ld = jsons.dump(l)
id = jsons.dump(i)
pd = jsons.dump(p)

print(ld)
print(id)
print(pd)

L = jsons.load(ld, Laboratory)
I = jsons.load(id, Institution)
P = jsons.load(pd, Person)

print(L)
print(I)
print(P)

From there we just need to write (read) the serialized objects to (from) a text file.

This feature has been added by 7bfbf53 and 722d89c, but it still needs to be documented in the README.