aperloff / WDTSscraper

Scrape WDTS produced PDF files for information about DOE run STEM pipeline programs.
0 stars 0 forks source link

Save and read in list of people #1

Open aperloff opened 2 years ago

aperloff commented 2 years ago

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.

aperloff commented 2 years ago

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