Start checking for geology reports - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Start checking for geology reports (/thread-10746.html) |
Start checking for geology reports - tjnichols - Jun-04-2018 Ok Lars60+ please know that everyone here and in Denver are signing your praises and sending you huge thank yous for helping me. Ok - that leads me to my next step. Let me know if you can think of an easier way. I would like to apply what I (think) have learned. I will post the code the way you have it written (in the typical Python format). I will then re-write it so it matches the new files to download and write what is new in a bold font. This API is an idea of what I can expect to see. There will be other files as well (especially cores) but it won't be often. http://wogcc.state.wy.us/wellapi.cfm?nApino=929594&oops=ID51558 Let me know if this works or perhaps you have a better idea. If so, I would love to hear it! Again, your help is most appreciated not only by me, but the rest of the geology department as well! RE: Start checking for geology reports - Larz60+ - Jun-04-2018 Give it a go, I or any other moderator would be glad to advise, but you caught me in a generous moment for the last one. Will always advise. Hint use dictionaries for code lookup: for example: class Codes: def __init__(self): self.GeologyCodes = { 'Well File Status': { 'PO': 'Producing Oil Well', 'PG': 'Producing Gas Well', 'DH': 'Dry Hole ', # Add rest of Well Status codes below 'AP': 'Permit to Drill' }, 'Classification': { 'O': 'Oil Well', 'G': 'Gas Well', # Rest of Classification codes below 'LW': 'LandOwner Water Well ' } # 'Land Types', 'County Codes', etc. below } # This dictionary can saved as a json file and recalles in any script that needs it: def print_code(self, cd_type, code): """ print_code(cd_type, code) Example: you get a well file status code from some data somewhere, and want to display that code :cd_type: Holds code type 'Well File Status', or 'Classification', etc. :code: Holds actual code like 'AP' :returns: None """ print(self.GeologyCodes[cd_type][code]) def try_status(self): """ try_status() test print_code :returns: None """ self.print_code('Well File Status', 'PG') code_type_from_file = 'Classification' code_from_file = 'LW' self.print_code(code_type_from_file, code_from_file) if __name__ == '__main__': cd = Codes() cd.try_status()results: Of course, dictionaries like this should be saved in appropriate directories as json data, and loaded when needed
|